{"id":13437015,"url":"https://github.com/tsherif/simple-opengl-loader","last_synced_at":"2025-10-28T12:43:24.784Z","repository":{"id":71745747,"uuid":"325309931","full_name":"tsherif/simple-opengl-loader","owner":"tsherif","description":"An extensible, cross-platform, single-header C/C++ OpenGL loader library.","archived":false,"fork":false,"pushed_at":"2022-08-26T10:50:14.000Z","size":601,"stargazers_count":89,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-16T07:04:50.740Z","etag":null,"topics":["linux","opengl","opengl-loader","single-header-lib","win32","windows","x11"],"latest_commit_sha":null,"homepage":"","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/tsherif.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2020-12-29T14:37:55.000Z","updated_at":"2025-02-28T06:20:43.000Z","dependencies_parsed_at":"2023-09-11T01:15:17.432Z","dependency_job_id":null,"html_url":"https://github.com/tsherif/simple-opengl-loader","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/tsherif%2Fsimple-opengl-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsherif%2Fsimple-opengl-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsherif%2Fsimple-opengl-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsherif%2Fsimple-opengl-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tsherif","download_url":"https://codeload.github.com/tsherif/simple-opengl-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243958259,"owners_count":20374831,"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":["linux","opengl","opengl-loader","single-header-lib","win32","windows","x11"],"created_at":"2024-07-31T03:00:53.743Z","updated_at":"2025-10-28T12:43:19.753Z","avatar_url":"https://github.com/tsherif.png","language":"C","funding_links":[],"categories":["C","Geometry, Graphics Processing, and Game Development"],"sub_categories":[],"readme":"Simple OpenGL Loader\n====================\n\nAn extensible, cross-platform, single-header C/C++ OpenGL loader library.\n\nUsage\n-----\nFor Windows Win32 or Linux X11 applications, the simplest usage involves defining `SOGL_MAJOR_VERSION`, `SOGL_MINOR_VERSION`and either `SOGL_IMPLEMENTATION_WIN32` or `SOGL_IMPLEMENTATION_X11` before including the `simple-opengl-loader.h` header file, and then calling `sogl_loadOpenGL()` after setting up an OpenGL context.\n\n```C\n    #define SOGL_MAJOR_VERSION 4\n    #define SOGL_MINOR_VERSION 5\n    #define SOGL_IMPLEMENTATION_WIN32 /* or SOGL_IMPLEMENTATION_X11 */\n    #include \"simple-opengl-loader.h\"\n\n    int main() {\n\n        /* Set up OpenGL context */\n        \n        sogl_loadOpenGL();\n\n        /* Use OpenGL functions */\n    }\n```\n\nIt is recommended that `simple-opengl-loader.h` be the first include to prevent other OpenGL headers from setting up their own definitions. \n\nPlatform support is included for Windows Win32 and Linux X11 applications by defining the `SOGL_IMPLEMENTATION_WIN32` or `SOGL_IMPLEMENTATION_X11` constants, respectively. The `SOGL_IMPLEMENTATION_X11` implementation requires the application be linked against `libdl`. See below to implement support for other platforms.\n\nOpenGL extensions can be loaded by defining a constant of the format `SOGL_\u003cextension name\u003e` before including the `simple-opengl-loader.h` header.\n\n```C\n    #define SOGL_MAJOR_VERSION 4\n    #define SOGL_MINOR_VERSION 5\n    #define SOGL_OVR_multiview\n    #define SOGL_KHR_parallel_shader_compile\n    #define SOGL_IMPLEMENTATION_WIN32\n    #include \"simple-opengl-loader.h\"\n```\n\nNote that the loader makes no guarantees about OpenGL version or extension support. `sogl_loadOpenGL()` returns a boolean value indicating whether it was able to load all requested functions, and the function `sogl_getFailures` returns a null-terminated array of the names of the functions that failed to load (up to a maximum defined by `SOGL_MAX_REPORTED_FAILURES`). \n\n```C\n    if (!sogl_loadOpenGL()) {\n        const char **failures = sogl_getFailures();\n        int i = 1;\n        while (*failures) {\n            fprintf(stderr, \"Failed to load function %s\\n\", *failures);\n            failures++;\n        }\n    }\n```\n\nPlatform Support\n----------------\n\nPlatform-specific logic is encapsulated in two functions `sogl_loadOpenGLFunction()` which takes the name of an OpenGL function as a null-terminated ASCII string and returns a pointer to the appropriate function, and `sogl_cleanup()`, which should perform any cleanup necessary after loading is complete, e.g. freeing library handles.\n\n```C\nvoid *sogl_loadOpenGLFunction(const char *name);\nvoid sogl_cleanup();\n```\n\nImplementations for these functions are provided out-of-the-box for Windows Win32 and Linux X11 applications (see above). Support for other platforms simply requires implementing these two functions for the target platform and defining the constant `SOGL_IMPLEMENTATION` instead of either of the platform-specific implementation constants.\n\n```C\n    #define SOGL_MAJOR_VERSION 4\n    #define SOGL_MINOR_VERSION 5\n    #define SOGL_IMPLEMENTATION\n    #include \"simple-opengl-loader.h\"\n\n    void *sogl_loadOpenGLFunction(const char *name) {\n        /* Custom function loader implementation */\n    }\n    \n    void sogl_cleanup() {\n        /* Custom cleanup implementation */ \n    }\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsherif%2Fsimple-opengl-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsherif%2Fsimple-opengl-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsherif%2Fsimple-opengl-loader/lists"}