{"id":13732047,"url":"https://github.com/septag/dds-ktx","last_synced_at":"2025-07-13T21:32:02.209Z","repository":{"id":149955046,"uuid":"153496070","full_name":"septag/dds-ktx","owner":"septag","description":"Single  header \"no-allocation\" KTX/DDS file reader","archived":false,"fork":false,"pushed_at":"2024-03-28T18:49:04.000Z","size":657,"stargazers_count":113,"open_issues_count":0,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-14T23:33:25.656Z","etag":null,"topics":["c","dds","directx","gamedev","image-loader","image-loading-library","khronos","ktx","opengl","single-header-lib","texture"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/septag.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-17T17:22:13.000Z","updated_at":"2024-11-02T23:46:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"fbe77407-0096-4ec5-be16-288650c7ba23","html_url":"https://github.com/septag/dds-ktx","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/septag%2Fdds-ktx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/septag%2Fdds-ktx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/septag%2Fdds-ktx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/septag%2Fdds-ktx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/septag","download_url":"https://codeload.github.com/septag/dds-ktx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225919900,"owners_count":17545375,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","dds","directx","gamedev","image-loader","image-loading-library","khronos","ktx","opengl","single-header-lib","texture"],"created_at":"2024-08-03T02:01:44.733Z","updated_at":"2024-11-22T15:29:05.569Z","avatar_url":"https://github.com/septag.png","language":"C","readme":"## dds-ktx: Portable single header DDS/KTX reader for C/C++\n[@septag](https://twitter.com/septagh)\n\n- Parses from memory blob. No allocations\n- No dependencies\n- Single-header for easy integration\n- Overridable libc functions \n\n### Build Example (ctexview)\n[**ctexview**](ctexview/ctexview.c) is a tiny ddx-ktx viewer that can be built on linux/mac and windows. To build it just compile the single file with your compiler.\n\n**Windows:**\n```\ncl ctexview.c /O2\n```\n\n**Linuxx**\n```\ngcc ctexview.c -O2 -lGL -ldl -lX11 -lXi -lXcursor -lm -o ctexview\n```\n\n**MacOS**\n```\nclang -framework Foundation -framework CoreServices -framework CoreFoundation -O2 -fobjc-arc -x objective-c -fmodules -x objective-c ctexview.c -o ./ctexview\n```\n\nto view images just provide the image path as an argument:\n\n```\nctexview [dds_or_ktx_image_file_path]\n```\n\nUsed open-source libraries for app creation/graphics: [**Sokol**](https://github.com/floooh/sokol)\n\n**Keys:**\n\n- UP/DOWN: change current mipmap\n- Apostrophe: change text color\n- F: Next cube-map face\n- R: Toggle Red channel\n- G: Toggle Green channel\n- B: Toggle Blue channel\n- A: Toggle Alpha channel\n\n### Usage\nIn this example, a simple 2D texture is parsed and created using OpenGL\n\n```c\n#define DDSKTX_IMPLEMENT\n#include \"dds-ktx.h\"\n\nint size;\nvoid* dds_data = load_file(\"test.dds\", \u0026size);\nassert(dds_data);\nddsktx_texture_info tc = {0};\nGLuint tex = 0;\nif (ddsktx_parse(\u0026tc, dds_data, size, NULL)) {\n    assert(tc.depth == 1);\n    assert(!(tc.flags \u0026 STC_TEXTURE_FLAG_CUBEMAP));\n    assert(tc.num_layers == 1);\n\n    //Create GPU texture from tc data\n    glGenTextures(1, \u0026tex);\n    glActiveTexture(GL_TEXTURE0);\n    glBindTexture(img-\u003egl_target, tex);\n\n    for (int mip = 0; mip \u003c tc-\u003enum_mips; mip++) {\n        ddsktx_sub_data sub_data;\n        ddsktx_get_sub(\u0026tc, \u0026sub_data, dds_data, size, 0, 0, mip);\n        // Fill/Set texture sub resource data (mips in this case)\n        if (ddsktx_format_compressed(tc.format))\n            glCompressedTexImage2D(..);\n        else\n            glTexImage2D(..);\n    }\n\n    // Now we can delete file data\n    free(dds_data);\n}\n```\n\n### Links\n- [DdsKtxSharp](https://github.com/rds1983/DdsKtxSharp): C# port of dds-ktx by [Roman Shapiro](https://github.com/rds1983)\n\n### TODO\n\n- Write KTX/DDS\n- Read KTX metadata. currently it just stores the offset/size to the metadata block\n  \n### Others\n\n- [stb_image](https://github.com/nothings/stb/blob/master/stb_image.h) - Single header library that loads images (.png, .jpg, .bmp, etc)\n- [bimg](https://github.com/bkaradzic/bimg) - Extensive C++ image library\n\n**NOTE**: Many parts of the code is taken from _bimg_ library.\n\n  \n[License (BSD 2-clause)](https://github.com/septag/dds-ktx/blob/master/LICENSE)\n--------------------------------------------------------------------------\n\n\u003ca href=\"http://opensource.org/licenses/BSD-2-Clause\" target=\"_blank\"\u003e\n\u003cimg align=\"right\" src=\"http://opensource.org/trademarks/opensource/OSI-Approved-License-100x137.png\"\u003e\n\u003c/a\u003e\n\n    Copyright 2018 Sepehr Taghdisian. All rights reserved.\n    \n    https://github.com/septag/dds-ktx\n    \n    Redistribution and use in source and binary forms, with or without\n    modification, are permitted provided that the following conditions are met:\n    \n       1. Redistributions of source code must retain the above copyright notice,\n          this list of conditions and the following disclaimer.\n    \n       2. Redistributions in binary form must reproduce the above copyright notice,\n          this list of conditions and the following disclaimer in the documentation\n          and/or other materials provided with the distribution.\n    \n    THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR\n    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO\n    EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\n    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n    OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\n    ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n","funding_links":[],"categories":["Graphics"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseptag%2Fdds-ktx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseptag%2Fdds-ktx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseptag%2Fdds-ktx/lists"}