osgx is a small, compiled C++20 utility layer on top of OpenSceneGraph. It modernizes common OSG idioms (concepts, ranges, spans, lambdas) and adds five optional, explicitly-included subsystems:
Note
The x in osgx just means "eXtras"; it has nothing to do with X11 or
anything else Xorg-centric (osgx::platform's X11/XRandr window helpers notwithstanding).
osgx::debug—GL_KHR_debugintegration (driver message callback, KHR debug-group annotations) plus a two-phase GPU/CPU per-drawable profiler.osgx::imgui— a Dear ImGui overlay (Widget/Panel) with pluggable sections and a built-in GPU-profiler, OSG-stats, and scene-texture browser.osgx::platform— X11/XRandr window helpers (alwaysOnTop,listMonitors,moveWindow), plus EGL- and GBM/DRM-backedGraphicsWindowfactories for driving a window without GLX or X11 at all.osgx::gltf— a glTF 2.0 loader (osgdb_gltf) producing generic osgx data (osgx::Material, skinning attributes), plus theosgx_environmentmanifest loader and the Khronos environment rotation. glTF content renders throughosgx::PBRScene(forward) orosgx::PBRGBuffer/PBRLightingPass(deferred).osgx::ktx2— a KTX2 texture reader/writer built on vendored KTX-Software, merged in alongsideosgx::gltffor the same reason (severalosgx::iblbake tools need KTX2 output).
All five live under osgx/ and use the osgx namespace, but none of them is included by the
osgx.hpp umbrella header — pulling in GL_KHR_debug, Dear ImGui, X11/EGL/GBM, the glTF loader, or
KTX-Software is always an explicit opt-in (#include "osgx/Debug.hpp" / #include "osgx/ImGui.hpp"
/ #include "osgx/Linux.hpp" / #include "osgx/gltf/Reader.hpp" / #include "osgx/ktx2/KTX2.hpp"),
never something a consumer gets for free just by including the umbrella.
See docs/ for the full per-subsystem reference, and the Gallery below for a look at what it renders.
osgx can be consumed directly from its source tree or as an installed CMake package. In either case, link the imported-style target and its OpenSceneGraph include and link requirements will be propagated to your target.
To embed the source tree in another project:
add_subdirectory(path/to/osgx EXCLUDE_FROM_ALL)
target_link_libraries(my_target PRIVATE osgx::osgx)When embedded, examples, utilities, the Python module, and installation rules are disabled by
default. They can be enabled individually with OSGX_BUILD_EXAMPLES, OSGX_BUILD_UTILS,
OSGX_BUILD_PYTHON, and OSGX_INSTALL.
To install osgx and consume it as a package, first install an already-configured build tree:
cmake --install BUILD --prefix /path/to/prefixThen use the installed package from the consuming project:
find_package(osgx CONFIG REQUIRED)
target_link_libraries(my_target PRIVATE osgx::osgx)Pass -DCMAKE_PREFIX_PATH=/path/to/prefix when configuring the consuming project if the chosen
prefix is not already in CMake's search path.
The same build tree can remove exactly the files recorded by its most recent install:
cmake --build BUILD --target uninstallThis uses CMake's generated install_manifest.txt; keep the build tree until the installation is
no longer needed.
Use osgx::core for the low-level, header-only facilities (Core.hpp, Array.hpp,
Callbacks.hpp, Shader.hpp, Visitors.hpp, Warnings.hpp) or osgx::osgx for the complete
utility layer, including osgx::debug/osgx::imgui/osgx::platform. osgx::osgx is the compiled
libosgx library and includes osgx::core.
osgx::gltf (the glTF loader) and osgx::ktx2 (the KTX2 reader/writer) are separate optional
static libraries, each gated behind its own OSGX_BUILD_GLTF/OSGX_BUILD_KTX2 option (default ON
at the top level, OFF when embedded). They used to live in a separate osgGLTF repo; both were
folded directly into this tree since they were never meaningfully independent of osgx::core/
osgx::osgx to begin with. See docs/GLTF.md.
osgx::headless is part of osgx::osgx, with no optional dependency beyond the platform backend:
it creates native or EGL pbuffers, runs a viewer for a fixed frame count, and captures the final
frame. See docs/HEADLESS.md.
osgx.hpp is the umbrella header for the always-available utility layer. It keeps common setup
code shorter and adds modern range/span/lambda-friendly wrappers. Its public headers are organized
by concern:
osgx/Core.hpp— smart-pointer helpers, timing, ring buffers,findDataFile(), and theObjectPath/vec_t/literal utilities.osgx/Visitors.hpp— scene-graph visitors, event handlers, andFilterNotifyHandler.osgx/Array.hpp—Array<BaseArray>/DrawElements<BaseElements>wrappers.osgx/Callbacks.hpp— callback-group and lambda-callback adapters.osgx/Picking.hpp— object-ID picking cameras, readback, and hover/click handlers.osgx/Manipulators.hpp—Ortho2DManipulator,OrbitAxisManipulator, andMultiCameraManipulator.osgx/Headless.hpp— offscreen native/EGL pbuffer creation, command-line parsing, and fixed-frame viewer capture.osgx/CameraActions.hpp—Viewpoint,FlyToCallback, andShakeCallback, driven by realosgAnimation::Motion/CompositeMotion(patrol legs, arrival latch, procedural shake).osgx/Grid.hpp— procedurally generated, antialiased grid overlay/ground-plane geometry.osgx/Shapes.hpp—Polyhedron-based primitive geometry (Cube,Tetrahedron,Octahedron,Icosahedron,Dodecahedron,PentagonalTrapezohedron) with explicit core-profile vertex attributes.osgx/Shader.hpp— generic, line-oriented GLSL library expansion.osgx/PBR.hpp— PBR BRDF snippets and theMaterialStateAttribute.osgx/Light.hpp— typed direct lights (LightSet: directional/point/sphere/spot) andOrbitLightRig.osgx/Gizmos.hpp—LightMarkers/LightGizmosscene-space visualizations forLightSetlights (depth-tested markers for point/sphere/spot, plus a directional-only overlay camera).osgx/Shadow.hpp— directional/spot/point shadow mapping (ShadowMap::create()/createSpot()/createPoint()), aggregated byShadowSetinto theHook::ShadowFactorslotLight.hpp's default direct-lighting hook always calls - any mix of lights can be shadowed at once, up toShadowSet's own compile-time caps.osgx/IBL.hpp— environment-map loading, BRDF-LUT baking (including the process-wideSharedBRDFLUT::create()cache), SH9/Lambertian diffuse irradiance, and cubemap readback helpers (readCubeMapFaces(),BRDFLUTReadback).osgx/CaptureCubeMap.hpp—CaptureCubeMap, the low-level frame-driven reflection-probe primitive (six ordered FBO cameras capturing a caller-owned scene into a cubemap).osgx/GGXPrefilter.hpp— GPU GGX prefilter scene construction, rebaking, and readback.osgx/LambertianBake.hpp— frame-driven GPU Lambertian/diffuse cubemap baking and readback (LambertianBake,LambertianCubeReadback).osgx/GBuffer.hpp— generic deferred G-buffer camera setup (GBuffer::create()), the primitiveosgx::PBRGBufferbuilds on.osgx/SSAO.hpp— hemisphere-kernel screen-space ambient occlusion (SSAO::create()) over any G-buffer's view-space normal + position channels.osgx/GTAO.hpp— horizon-based Ground Truth Ambient Occlusion (GTAO::create()), a GLSL port of Intel's XeGTAO, with the same inputs and output asSSAO.osgx/CORTAO.hpp— Circular Occluder Ray-Traced Ambient Occlusion (CORTAO::create()), the CORTAO reference shaders ported to GLSL, with the same inputs and output asSSAO.osgx/ComputePass.hpp—ComputePass, one compute dispatch plus the memory barrier its consumers need; the building block ofGTAOandCORTAO.osgx.hpp— convenience umbrella that includes all of the above (but notosgx::debugorosgx::imgui— see Documentation below).osgx/Version.hpp—OSGX_VERSION_MAJOR/MINOR/PATCHand theOSGX_VERSIONstring, generated from the CMake project version.
Note
If you want to avoid having to make install before testing locally, you can
use a command like the following: export OSG_LIBRARY_PATH="$PWD/plugins/gltf:$PWD/plugins/ktx2${OSG_LIBRARY_PATH:+:$OSG_LIBRARY_PATH}"
This will ensure your local build's osgdb_{ktx2,gltf} files are used
instead.
Per-subsystem deep dives live in docs/:
osgxcore — everything above that lives flat inosgx:::Core,Visitors,Array,Callbacks,Picking,Manipulators,CameraActions,Grid,Shapes,Shader,PBR,Gizmos,Shadow,IBL,GBuffer,Cursor,Projection, and the cubemap-baking primitives it's built on.osgx::debug— the threeGL_KHR_debugsystems, the two-phase GPU/CPU profiler, andFrameByFrameViewer.osgx::imgui— the Dear ImGui overlay.osgx::platform— X11/XRandr and the EGL/GBMGraphicsWindowfactories.osgx::headless— portable fixed-frame offscreen rendering and capture, with EGL selected automatically when available.osgx::gltf— the loader, its shader interface, the optional PBR/IBL renderer, and the environment-baking tool.
| Preview | Description |
|---|---|
|
glTF PBR/IBL parity
|
More screenshots — one per example — are planned; this table is set up to grow.
