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

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 */ 
    }
Owner
Similar Resources

Cross-platform, efficient, customizable, and robust asynchronous HTTP/WebSocket server C++14 library with the right balance between performance and ease of use

What Is RESTinio? RESTinio is a header-only C++14 library that gives you an embedded HTTP/Websocket server. It is based on standalone version of ASIO

Nov 25, 2022

Cross-platform library for building Telegram clients

TDLib (Telegram Database library) is a cross-platform library for building Telegram clients. It can be easily used from almost any programming language.

Nov 17, 2022

A cross-platform HTTP client library with a focus on usability and speed

EasyHttp A cross-platform HTTP client library with a focus on usability and speed. Under its hood, EasyHttp uses POCO C++ Libraries and derives many o

Nov 9, 2022

Tiny cross-platform HTTP / HTTPS client library in C.

naett /nɛt:/ Tiny HTTP client library in C. Wraps native HTTP client functionality on macOS, Windows, Linux, iOS and Android in a single, simple non-b

Nov 19, 2022

Small and fast cross-platform networking library, with support for messaging, IPv6, HTTP, SSL and WebSocket.

frnetlib Frnetlib, is a cross-platform, small and fast networking library written in C++. There are no library dependencies (unless you want to use SS

May 16, 2022

XQUIC Library released by Alibaba is a cross-platform implementation of QUIC and HTTP/3 protocol.

XQUIC Library released by Alibaba is a cross-platform implementation of QUIC and HTTP/3 protocol.

XQUIC 简体中文文档 README-zh-CN Introduction XQUIC Library released by Alibaba is … … a client and server implementation of QUIC and HTTP/3 as specified by

Nov 17, 2022

RakNet is a cross platform, open source, C++ networking engine for game programmers.

RakNet 4.081 Copyright (c) 2014, Oculus VR, Inc. Package notes The Help directory contains index.html, which is full help documentation in HTML format

Nov 19, 2022

LibVNCServer/LibVNCClient are cross-platform C libraries that allow you to easily implement VNC server or client functionality in your program.

LibVNCServer: A library for easy implementation of a VNC server. Copyright (C) 2001-2003 Johannes E. Schindelin If you already used LibVNCServer, you

Nov 24, 2022

RakNet is a cross platform, open source, C++ networking engine for game programmers.

RakNet 4.081 Copyright (c) 2014, Oculus VR, Inc. Package notes The Help directory contains index.html, which is full help documentation in HTML format

Nov 19, 2022
Brynet - Header Only Cross platform high performance TCP network library using C++ 11.
Brynet - Header Only Cross platform high performance TCP network library using C++ 11.

Brynet Header Only Cross platform high performance TCP network library using C++ 11. Build status Windows : Linux/MacOS : Features Header only Cross p

Nov 26, 2022
Cross-platform, single .h file HTTP server (Windows, Linux, Mac OS X)

EWS - Single .h File C Embeddable Web Server Latest Version: 1.1.4 released September 9, 2021 Supported platforms: Linux, Mac OS X, Windows License: B

Oct 17, 2022
modern c++(c++17), cross-platform, header-only, easy to use http framework
modern c++(c++17), cross-platform, header-only, easy to use http framework

cinatra--一个高效易用的c++ http框架 English | 中文 目录 使用cinatra常见问题汇总(FAQ) cinatra简介 如何使用 快速示例 性能测试 注意事项 roadmap 联系方式 cinatra简介 cinatra是一个高性能易用的http框架,它是用modern

Nov 16, 2022
The C++ Network Library Project -- cross-platform, standards compliant networking library.

C++ Network Library Modern C++ network programming libraries. Join us on Slack: http://slack.cpp-netlib.org/ Subscribe to the mailing list: https://gr

Nov 11, 2022
single header C(99) library to implement client-server network code for games

single header C(99) library to implement client-server network code for games

Nov 10, 2022
A single-header socket library for both Linux and Windows

COMS What is COMS? COMS is a single-header library designed to be simple to use. It supports TCP and UDP, Server and Client. Available for Windows and

Dec 23, 2021
Minimalistic socket library inspired by Asio/Boost Asio, implemented in 1 single header file

cz-spas czspas (Small Portable Asynchronous Sockets) is minimalistic socket library inspired by Asio/Boost Asio, implemented in 1 single header file.

Jun 12, 2022
A lightweight plugin loader for Bedorck Dedicated Server

LiteLoader 简体中文 Donate us(afdian) Forum A lightweight Bedorck Dedicated Server Plugin Loader Based on BedrockX Install Download LiteLoader from Releas

Nov 21, 2022
WslinkClient is a client intended to communicate with Wslink, which is a unique loader running as a server

WslinkClient WslinkClient is a client intended to communicate with Wslink, which is a unique loader running as a server and executing received modules

Apr 19, 2022
Project Ares is a Proof of Concept (PoC) loader written in C/C++ based on the Transacted Hollowing technique

Project Ares Project Ares Injector Project Ares Injector is a Proof of Concept (PoC) loader written in C/C++ based on the Transacted Hollowing techniq

Nov 15, 2022