{"id":16984236,"url":"https://github.com/floooh/gliml","last_synced_at":"2025-03-22T15:30:43.042Z","repository":{"id":15136212,"uuid":"17863462","full_name":"floooh/gliml","owner":"floooh","description":"Minimalistic image loader library for GL projects","archived":false,"fork":false,"pushed_at":"2018-03-10T13:38:51.000Z","size":36,"stargazers_count":64,"open_issues_count":0,"forks_count":9,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-18T13:15:10.400Z","etag":null,"topics":["fips"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/floooh.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}},"created_at":"2014-03-18T11:33:14.000Z","updated_at":"2025-03-16T06:56:18.000Z","dependencies_parsed_at":"2022-07-22T11:47:28.153Z","dependency_job_id":null,"html_url":"https://github.com/floooh/gliml","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floooh%2Fgliml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floooh%2Fgliml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floooh%2Fgliml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floooh%2Fgliml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/floooh","download_url":"https://codeload.github.com/floooh/gliml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244978403,"owners_count":20541849,"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":["fips"],"created_at":"2024-10-14T02:30:41.075Z","updated_at":"2025-03-22T15:30:42.735Z","avatar_url":"https://github.com/floooh.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"gliml\n=====\n\n(work in progress!)\n\nMinimalistic image loader library for GL projects:\n\n- header only, just include a header and optionally set a few defines to enable or disable features\n- focus on compressed formats that can be dumped right into GL texture objects\n- doesn't use C++ exceptions, RTTI, STL, strings or file functions\n- doesn't call into GL, doesn't include GL headers\n- no dynamic memory allocation\n- overridable assert macro\n\nFile formats: DDS, PVR, KTX\n\nTexture formats: DXT1, DXT3, DXT5, PVR2BPP, PVR4BPP, ETC2\n\nBasic usage:\n\n1. load file data into memory\n2. create **gliml::context** object \n3. enable DXT, PVR, ETC2 support depending on GL extensions/version\n3. call **gliml::context::load()** to parse the file data into the gliml::context object\n4. setup a GL texture using the data in the gliml::context object\n\nSee Oryol for real-world example:\n\nhttps://github.com/floooh/oryol/blob/master/code/Modules/Assets/Gfx/TextureLoader.cc\n\nSample code (WIP):\n\n```cpp\n#define GLIML_ASSERT(x) my_assert(x)\n#include \"gliml/gliml.h\"\n\nvoid glimlSample() {\n\n    // load file into memory (gliml doesn't have any file I/O functions)\n    std::ifstream file(\"my_texture.dds\", std::ios::in | std::ios::binary);\n    fil.seekg(0, std::ios::end);\n    int size = file.tellg();\n    file.seekg(0, std::ios::beg);\n    std::vector\u003cunsigned char\u003e buffer(size);\n    file.read(buffer.data(), size);\n    file.close();\n    \n    // check GL for DXT / PVR support\n    bool hasDXTExtension = ...;\n    bool hasPVRTCExtension = ...;\n    bool hasETC2 = ...;\n\n    // now extract the file data into GL data using gliml\n    gliml::context ctx;\n    ctx.enable_dxt(hasDXTExtension);   \n    ctx.enable_pvrtc(hasPVRTCExtension);\n    ctx.enable_etc2(hasETC2)\n    if (ctx.load(\u0026buffer.front(), size)) {\n        \n        // create a GL texture\n        GLuint gltx;\n        glGenTextures(1, \u0026gltx);\n        glBindTexture(ctx.texture_target(), gltx);\n\n        // set desired texture params\n        glTexParameteri(ctx.texture_target(), GL_TEXTURE_WRAP_S, GL_REPEAT);\n        glTexParameteri(ctx.texture_target(), GL_TEXTURE_WRAP_T, GL_REPEAT);\n        if (ctx.is_3d()) {\n            glTexParameteri(ctx.texture_target(), GL_TEXTURE_WRAP_R, GL_REPEAT);\n        }\n        glTexParameteri(ctx.texture_target(), GL_TEXTURE_MAG_FILTER, GL_LINEAR);\n        if (ctx.num_mipmaps(0) \u003e 1) {\n            glTexParameteri(ctx.texture_target(), GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);\n        else {\n            glTexParameteri(ctx.texture_target(), GL_TEXTURE_MIN_FILTER, GL_LINEAR);\n        }\n  \n        // for each (cube-map) face...\n        for (int face_index = 0; face_index \u003c ctx.num_faces(); face_index++) {\n            // for each mip-map level\n            for (int mip_index = 0; mip_index \u003c ctx.num_mipmaps(face_index); mip_index++) {\n                if (ctx.is_compressed()) {\n                    // compressed\n                    if (ctx.is_2d()) {\n                        // compressed 2D or cube texture\n                        glCompressedTexImage2D(ctx.image_target(face_index),\n                                               mip_index,\n                                               ctx.image_internal_format(),\n                                               ctx.image_width(face_index, mip_index),\n                                               ctx.image_height(face_index, mip_index),\n                                               0,\n                                               ctx.image_size(face_index, mip_index),\n                                               ctx.image_data(face_index, mip_index));\n                    }\n                    else {\n                        // compressed 3D texture\n                        assert(ctx.is_3d());\n                        glCompressedTexImage3D(ctx.image_target(face_index),\n                                               mip_index,\n                                               ctx.image_internal_format(),\n                                               ctx.image_width(face_index, mip_index),\n                                               ctx.image_height(face_index, mip_index),\n                                               ctx.image_depth(face_index, mip_index),\n                                               0,\n                                               ctx.image_size(face_index, mip_index),\n                                               ctx.image_data(face_index, mip_index));\n                    }\n                }\n                else {\n                    // uncompressed\n                    if (ctx.is_2d()) {\n                        // 2D or CUBE texture\n                        glTexImage2D(ctx.image_target(face_index),\n                                     mip_index,\n                                     ctx.image_internal_format(),\n                                     ctx.image_width(face_index, mip_index),\n                                     ctx.image_height(face_index, mip_index),\n                                     0,\n                                     ctx.image_format(),\n                                     ctx.image_type(),\n                                     ctx.image_data(face_index, mip_index));\n                    }\n                    else {\n                        // 3D texture\n                        assert(ctx.is_3d());\n                        glTexImage3D(ctx.image_target(face_index),\n                                     mip,\n                                     ctx.image_internal_format(),\n                                     ctx.image_width(face_index, mip_index),\n                                     ctx.image_height(face_index, mip_index),\n                                     ctx.image_depth(face_index, mip_index),\n                                     0,\n                                     ctx.image_format(),\n                                     ctx.image_type(),\n                                     ctx.image_data(face_index, mip_index));\n                    }\n                }\n            } // for mip...\n        } // for face...\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloooh%2Fgliml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffloooh%2Fgliml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloooh%2Fgliml/lists"}