Repository navigation
OpenGL Backend
Release boundary: This page documents an experimental implementation outside the blocked and uncertified
stable-v1product scope (Windows 11 x64/MSVC v143 with D3D11 or Windows NullRHI and C++ modules). It is not a supported or release-certified backend.
Experimental OpenGL RHI development implementation. The direct EGL/GLX device path requests a 4.5 context, while the SDL runtime/editor hosts request 3.3; source-level DSA and SPIR-V paths still depend on the context and driver that is actually created. It is not a generic or certified fallback.
-
Namespace:
Spark::RHI::OpenGL -
Files:
Graphics/RHI/OpenGL/OpenGLDevice.{h,cpp}(~450 LOC header). -
Guard:
#ifdef SPARK_OPENGL_SUPPORT(CMake toggleENABLE_OPENGL=ON). -
Linkage: GLAD loader (bundled in
ThirdParty/) + SDL2 for context creation. - Context/feature boundary: EGL/GLX requests OpenGL 4.5; SDL hosts request 3.3. DSA and SPIR-V binary-shader calls exist in source but are not a blanket OpenGL 4.6 runtime guarantee.
| Class | Purpose | RHI interface |
|---|---|---|
GLDevice |
Context owner, resource factory | IRHIDevice |
GLBuffer |
glCreateBuffers + DSA upload |
IRHIBuffer |
GLTexture |
glCreateTextures + optional framebuffer attachment |
IRHITexture |
GLShader |
Program or separable shader object | IRHIShader |
GLSampler |
glCreateSamplers state |
IRHISampler |
GLPipelineState |
VAO + pipeline composition | IRHIPipelineState |
GLSwapChain |
SDL2-backed double-buffer swap | IRHISwapChain |
GLCommandList |
Immediate-mode translation (no real GL command buffer) | IRHICommandList |
OpenGL is single-threaded — command recording is serialized on the render thread.
-
Direct state access (DSA) — all resource creation uses the DSA variants (
glCreateTextures,glNamedBufferStorage, etc.). Cleaner than bind-to-modify. -
SPIR-V ingest — shader loading accepts compiled SPIR-V binaries via
glShaderBinary(GL_SHADER_BINARY_FORMAT_SPIR_V), so the offline shader cook path produces one binary format for both OpenGL and Vulkan. -
Mesa
llvmpipedevelopment route — requires explicit Mesa/driver and headless-display configuration; it is not a generic CI or release-certified fallback. See the RHI fallback chain. -
KHR_debug callback — validation messages routed through
Spark::Loggerin debug builds. -
Persistent-mapped buffers —
GL_MAP_PERSISTENT_BITused for per-frame transient UI / debug-draw streams. -
Framebuffer object (FBO) abstraction —
GLTexture::SetFramebuffercaches the FBO that owns this texture as a color/depth attachment, avoiding per-draw-call FBO churn.
auto& caps = device->GetCapabilities();
caps.maxTextureSize // GL_MAX_TEXTURE_SIZE
caps.computeShaderSupport // true on 4.3+
caps.bindlessResourceSupport // GL_ARB_bindless_texture (NVIDIA)
caps.meshShaderSupport // GL_NV_mesh_shader (experimental)// RHIFactory.cpp
case GraphicsBackend::OpenGL:
device = std::make_unique<OpenGL::GLDevice>();
break;RHIFactory::GetRecommendedBackend() selects a preferred compiled and available backend; it does not retry device startup. RHIBridge::Initialize tries available GPU candidates after device or swap-chain failure and creates NullRHIDevice only if they all fail. OpenGL is one optional candidate, not a NullRHI fallback tier.
-
No timeline semaphores — CPU/GPU sync via
glFenceSync/glClientWaitSync. - No bindless (standard) — vendor-specific extensions only.
- No ray tracing, no mesh shaders (portable) — upgrade to Vulkan or D3D12 for those.
- Single thread — render commands must run on the thread that created the context.
- RHI Abstraction Layer
- Vulkan Backend — experimental Linux development alternative when compiled.
- D3D11 Backend — Windows equivalent tier.
- Shader Pipeline — how shaders are built into the SPIR-V blobs that OpenGL consumes.
Published from 2b03dc797148. Edit the canonical source in wiki/.
- Documentation
- Docs route
- Wiki index
- Guides
- Tutorials
- Samples
- Examples
- API Reference
- API route
- Reference
- Build Guide
- Dependencies
- FAQ
- Changelog
- Roadmap
- Contributing
- Code of Conduct
- Home
- FAQ
- Getting Started
- Quick-Start Tutorial
- Making Your First Game
- Making Your First Multiplayer Game
- Artist Workflow Guide
- Editor Walkthrough
- Migration Guide
- How SparkEngine Works
- Architecture Overview
- Engine Architecture Flowchart
- Creating a Game Module
- Game Modules (catalog)
- Entity Component System
- Rendering and Graphics
- Physics
- Cloth Simulation
- Audio
- Input System
- Camera System
- Scripting with AngelScript
- Visual Scripting
- AI and Navigation
- Animation
- 2D Systems
- Networking
- Dedicated Server
- Multiplayer Quick Start
- Area Server Architecture
- Scene Management
- Large World Support
- Collaborative Editing
- Coroutine System
- Event System
- Event Response System
- Job System
- UI System
- UI Layout Extensions
- Localization
- Dialogue System
- Destruction System
- Replay System
- Achievement System
- Loading System
- Mod System
- Content Delivery
- Tween System
- Memory Integrity
- Gameplay Systems
- Terrain and Procedural Generation
- Save System
- Persistence System
- Day Night Cycle and Weather
- Cinematic Sequencer
- Runtime Prefabs
- SparkEditor
- Editor Tutorials
- SparkConsole
- SparkDaemon
- Shader Pipeline
- Asset Pipeline
- Asset Validation
- Asset Migration
- Game Packaging
- Online Services
- DataTable System
- Loot and Crafting System
- CSG System
- Font System
- Timer Manager
- Movie Render Pipeline
- HLOD and World Partition
- Remote Debug System
- Selection Manager
- Asset Dependency Graph
- Editor Automation
- File Watcher
- Project Templates
- System Requirements
- VR Support
- Mobile Platform
- Accessibility
- Platform Input
- Platform Certification
- Cross-Compilation: Wine Testing
- RHI Abstraction Layer
- D3D11 Backend
- D3D12 Backend
- Vulkan Backend
- OpenGL Backend
- Metal Backend
- DXR Raytracing
- Hybrid Ray Tracing
- Upscaling (DLSS/FSR)
- Render Graph
- Shader Graph
- GPU Particles
- GPU-Driven Rendering
- Volumetric Fog
- Volumetric Clouds
- Global Illumination
- Virtual Texturing
- Water Rendering
- Clustered Lighting
- Material System
- Post-Processing
- Shadow System
- Particle System
- Decal System
- Sky and Atmosphere
- Foliage System
- Mesh Shaders
- Neural Rendering
- Configuration Reference
- Performance Tips
- Benchmark Framework
- Threading Model
- Fuzz Policy and Parser Security
- Memory Safety
- Memory Management Patterns
- Build System and CMake Modules
- Profiler and Debugging
- Performance Profiling Guide
- Telemetry System
- Crash Reporting
- Golden Image Testing
- Utilities
- Testing
- Fuzz Policy and Parser Security
- Codebase Statistics
- Codebase Health
- Error Handling Patterns
- Hot Reload Overview
- Troubleshooting
- Contributing
- Workflow Patterns
- Build Optimizations
- CI Reproducible Builds
- GitHub API and PR Checks
- Git Rebase Conflicts
- Clang-Format
- Code Quality Violations
- AI Bloat Pattern
- MinGW + Wine Cross-Compilation
- Live Editor Testing
- Engine & Renderer Landscape
- DuetOS Portability Catalog
- Five-Engine Analysis
- Eleven-Engine Analysis
- ThorVG / Unity Graphics Analysis
- Advanced Techniques Catalog
- Third-Party Library Evaluation
- Engine Viability Evaluation
- Engine Feature Recommendations
- Project Recommendations
- Mac Compatibility Analysis
- Codebase Observations
- Codebase Bloat Audit
- Test Suite Audit
- Documentation Coverage Audit
- ThirdParty Dependencies Audit
- Load Test Baseline
- Gameplay Systems Status
- SparkGame Module Status
- Stub and Abandoned Features
- Memory Integrity System
- Memory Safety Evaluation
- Hardware Acceleration Systems
- Jolt Physics Integration
- GPU/CPU Separation Plan
- Daemon Services Architecture
- Reflection & Polymorphism Refactoring Plan
- SparkBuild In-Tree
- Wine No-JobSystem Breakthrough
- Wine Role and Fallback Tiers