All Projects → tsherif → simple-opengl-loader

tsherif / simple-opengl-loader

Licence: MIT License
An extensible, cross-platform, single-header C/C++ OpenGL loader library.

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to simple-opengl-loader

eseed-window
A minimal cross-platform C++17 window management library for rendering (deprecated)
Stars: ✭ 18 (-74.65%)
Mutual labels:  x11, win32
Wxwidgets
wxWidgets is a free and open source cross-platform C++ framework for writing advanced GUI applications using native controls.
Stars: ✭ 3,994 (+5525.35%)
Mutual labels:  x11, win32
wae
An async executor based on the Win32 thread pool API
Stars: ✭ 10 (-85.92%)
Mutual labels:  win32
tint3
A C++ rewrite of the tint2 panel
Stars: ✭ 39 (-45.07%)
Mutual labels:  x11
gnome-gesture-improvements
Touchpad gesture improvements for GNOME on Wayland/X11
Stars: ✭ 53 (-25.35%)
Mutual labels:  x11
Hello-GLUT
A very simple "Hello World!" GLUT application demonstrating how to write OpenGL applications in C with MinGW and MSVC.
Stars: ✭ 27 (-61.97%)
Mutual labels:  win32
desktop-tux
WIP desktop-goose clone for X11/Linux
Stars: ✭ 20 (-71.83%)
Mutual labels:  x11
gone
Where has my time gone?
Stars: ✭ 46 (-35.21%)
Mutual labels:  x11
scalaui
Scala Native GUI framework based on libui
Stars: ✭ 56 (-21.13%)
Mutual labels:  win32
x11-cr
X11 bindings for Crystal language.
Stars: ✭ 32 (-54.93%)
Mutual labels:  x11
dllhook
A tool for hooking Windows applications and jumping to your Python code with the injected Python interpreter
Stars: ✭ 20 (-71.83%)
Mutual labels:  win32
SoftwareHelper
This is a windows app shortcut widget 🔨
Stars: ✭ 122 (+71.83%)
Mutual labels:  win32
DLL-Injector
Inject and detour DLLs and program functions both managed and unmanaged in other programs, written (almost) purely in C#. [Not maintained].
Stars: ✭ 29 (-59.15%)
Mutual labels:  win32
gobble
Rust rewrite of Devour
Stars: ✭ 23 (-67.61%)
Mutual labels:  x11
x11-clipboard
x11 clipboard support for Rust
Stars: ✭ 28 (-60.56%)
Mutual labels:  x11
magic-mirror-raspbian-lite
Magic Mirror for Raspbian Lite (works with Raspberry Pi Zero)
Stars: ✭ 25 (-64.79%)
Mutual labels:  x11
zig-opengl
OpenGL binding generator based on the opengl registry
Stars: ✭ 29 (-59.15%)
Mutual labels:  opengl-loader
CherryLib
Win32/MFC UI Control, Live Update, Utility Library
Stars: ✭ 19 (-73.24%)
Mutual labels:  win32
vswm
A very stupid window manager.
Stars: ✭ 28 (-60.56%)
Mutual labels:  x11
programming-windows-5th-edition
Unofficial source code repo for Charles Petzold's Programming Windows 5th Edition.
Stars: ✭ 28 (-60.56%)
Mutual labels:  win32

Simple OpenGL Loader

An extensible, cross-platform, single-header C/C++ OpenGL loader library.

Usage

For Windows Win32 or Linux X11 applications, the simplest usage involves defining SOGL_MAJOR_VERSION, SOGL_MINOR_VERSIONand 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.

    #define SOGL_MAJOR_VERSION 4
    #define SOGL_MINOR_VERSION 5
    #define SOGL_IMPLEMENTATION_WIN32 /* or SOGL_IMPLEMENTATION_X11 */
    #include "simple-opengl-loader.h"

    int main() {

        /* Set up OpenGL context */
        
        sogl_loadOpenGL();

        /* Use OpenGL functions */
    }

It is recommended that simple-opengl-loader.h be the first include to prevent other OpenGL headers from setting up their own definitions.

Platform 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.

OpenGL extensions can be loaded by defining a constant of the format SOGL_<extension name> before including the simple-opengl-loader.h header.

    #define SOGL_MAJOR_VERSION 4
    #define SOGL_MINOR_VERSION 5
    #define SOGL_OVR_multiview
    #define SOGL_KHR_parallel_shader_compile
    #define SOGL_IMPLEMENTATION_WIN32
    #include "simple-opengl-loader.h"

Note 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).

    if (!sogl_loadOpenGL()) {
        const char **failures = sogl_getFailures();
        int i = 1;
        while (*failures) {
            fprintf(stderr, "Failed to load function %s\n", *failures);
            failures++;
        }
    }

Platform Support

Platform-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.

void *sogl_loadOpenGLFunction(const char *name);
void sogl_cleanup();

Implementations 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.

    #define SOGL_MAJOR_VERSION 4
    #define SOGL_MINOR_VERSION 5
    #define SOGL_IMPLEMENTATION
    #include "simple-opengl-loader.h"

    void *sogl_loadOpenGLFunction(const char *name) {
        /* Custom function loader implementation */
    }
    
    void sogl_cleanup() {
        /* Custom cleanup implementation */ 
    }
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].