GLUS is a cross-platform utility library for OpenGL, OpenGL ES and OpenVG. It provides window/context creation, math helpers, image and model loading, shader utilities and more. GLUS lives in its own repository and is used by the McNopper/OpenGL examples.
Security and correctness fixes across parsers, math, and platform layers:
- TGA loader: bounded the RLE packet against the remaining output buffer (heap overflow); validated colour-map indices; skipped the Image ID field; validated
colorMapEntrySize; endian-safe dimension decoding. - HDR (Radiance) loader: bounded the resolution-line read (stack overflow); checked
sscanfreturn and validated dimensions (uninitialised variable / integer overflow); fixed signed-char comparison breaking new-style RLE for common widths. - glTF loader: call
cgltf_validate()(arbitrary read/write primitives); clamp accessor component copy loop (heap overflow); validate morph-target and animation sampler sizes; add recursion depth guard; check all allocations; key texture cache on sRGB flag; reject path-traversal URIs. - Wavefront OBJ/MTL loader: bounded all
sscanfconversions (%31s/%255s); bounds-checked face indices with relative-index resolution; fixed unsigned underflow in fan triangulation; NULL-guarded material pointer; bounded struct-field string copies. - Math: guard Perlin
% amplitudeagainst zero (SIGFPE); fix tangent-loop out-of-bounds write; add quaternion slerp shortest-path; fix vector reflect aliasing; fix disc UV formula; clampacosf/asinfdomains; fix oriented-box inverse rotation order. - Shape generators: tighten
glusShapeCreateDomefminimum; guard degenerate-UV tangent determinant; validate adjacency edge indices. - Program: fix shader/program leaks on compile/link failure paths; handle zero-length info logs.
- Window/OS: fix
toloweron GLFW key codes (UB); fix button-release XOR (phantom held button); update cached dimensions on resize; checkXOpenDisplayresult; fix X resource leaks; fixglusExtensionIsSupportedon core-profile contexts. - Memory: raise
glus_memory_nodmalignment tomax_align_t. - Files: fix
fopen(NULL)UB; fixftelltruncation into 32-bitGLUSint; treat short writes as errors.
- Added a glTF 2.0 core loader module (
glus_gltf.h/glus_gltf.c): parses.glb/.gltfvia cgltf and uploads render-ready primitives that match the GLUS glTF PBR shaders. Covers the full core spec — scenes / node hierarchy (TRS and matrix), meshes (all primitive modes), PBR metallic-roughness materials, textures / samplers / images (external, GLB embedded anddata:URIs), sparse accessors, skins, TRS animation (STEP / LINEAR / CUBICSPLINE), morph targets and cameras. Khronos / vendor extensions are not interpreted by GLUS; the parsed cgltf tree stays reachable throughglusGltfGetCgltfData()so each application can read the extension data it needs (e.g.KHR_gaussian_splatting) itself. - GLUS now fetches cgltf and stb (stb_image) and exposes their include
directories publicly, and defines
GLUS_SHADER_DIR(the absolute path to GLUS'shader/directory) so applications load the glTF / IBL shaders straight from this source tree.
- Fixed two sign errors in the band-3 spherical-harmonics rotation
(
glusSHBuildRotation3f) that made the band-3 matrix non-orthogonal. Verified (orthogonality, group homomorphism, equivariance) against andrewwillmott/sh-lib. - Documented the SH rotation basis/convention in
glus_sh.h(standard real SH; bridge to the Inria/3DGS/glTF sign convention via the Condon-Shortley phase).
- Initial public release.
- CMake 3.14 or higher - Download CMake
- C/C++ Compiler:
- Windows: Visual Studio 2013 or newer (MSVC)
- Linux: GCC or Clang
- macOS: Xcode Command Line Tools (Clang)
- Git - For fetching dependencies
- OpenGL 3.2+ compatible graphics driver
cmake -S . -B build
cmake --build build --config ReleaseThis produces the static library lib/GLUS.lib (or lib/libGLUS.a on
Linux/macOS).
GLUS can be consumed directly via CMake FetchContent:
include(FetchContent)
FetchContent_Declare(
glus
GIT_REPOSITORY https://github.com/McNopper/GLUS.git
GIT_TAG main
)
FetchContent_MakeAvailable(glus)
target_link_libraries(your_target PRIVATE GLUS)For the desktop OpenGL build, the following are automatically fetched and built
via CMake FetchContent - no manual installation required:
- GLFW 3.4 - https://github.com/glfw/glfw - window and input management
- GLEW 2.2.0 - https://github.com/Perlmint/glew-cmake - OpenGL extension loading
- cgltf v1.14 - https://github.com/jkuhlmann/cgltf - glTF 2.0 parser (used by the glTF loader)
- stb (stb_image) - https://github.com/nothings/stb - image decoding (used by the glTF loader)
When GLUS is added to a parent project that already provides these targets, the existing ones are reused instead of being fetched again.
GLUS is MIT licensed (see LICENSE). The desktop OpenGL build depends on the following third-party projects, which are fetched automatically and are not part of the GLUS source tree:
- GLFW 3.4 - https://github.com/glfw/glfw - zlib/libpng license
- GLEW 2.2.0 (via glew-cmake) - MIT / BSD
- cgltf v1.14 - https://github.com/jkuhlmann/cgltf - MIT (Copyright (c) 2018-2021 Johannes Kuhlmann). Compiled into the GLUS static library through
CGLTF_IMPLEMENTATIONby the glTF loader (glus_gltf.c). - stb / stb_image - https://github.com/nothings/stb - MIT / Public Domain (Copyright (c) 2017 Sean Barrett). Compiled into the GLUS static library through
STB_IMAGE_IMPLEMENTATIONby the glTF loader (glus_gltf.c).
Because cgltf and stb_image are compiled into GLUS, their copyright and
permission notices are redistributed with any binary that links GLUS, as
required by their licenses.
OpenGL ES 2.0/3.0/3.1 and OpenVG builds are selected via the OpenGL CMake
variable (e.g. -DOpenGL=ES2, -DOpenGL=ES, -DOpenGL=ES31). An Android NDK
build is available under Android/jni.
API documentation can be generated with Doxygen:
cd docs
doxygen DoxyfileThe HTML output is written to docs/html.
Yours Norbert Nopper