easy-gl
Documentation
easy-gl is a modern C++20 RAII wrapper around OpenGL. It provides safe resource ownership, convenient high-level methods, and full type safety — all delegating low-level calls to meta-gl instead of raw OpenGL.
What easy-gl gives you
- Move-only RAII resource classes — textures, buffers, programs, framebuffers all clean up automatically.
- Type-safe OpenGL enums from meta-gl — no more integer constants scattered through your code.
- A Device class that centralises all render-state mutations and draw calls.
- Full C++20 —
std::span,enum class, constexpr, concepts where they help. - No dependency on raw OpenGL headers in your application code.
Layer diagram
std::spanResource classes at a glance
Buffer
Vertex, index, uniform, SSBO and other GPU buffer types.
Texture
2D, 3D, array, cubemap textures with mipmap generation.
Shader
Vertex, fragment, geometry, compute shader compilation.
Program
Link shaders, set uniforms, use programs.
VertexArray
Vertex attribute layout definition and VAO management.
Framebuffer
Offscreen rendering targets with attachment management.
Renderbuffer
Depth/stencil storage for framebuffer attachments.
Sampler
Decoupled texture sampling parameters.
Query
Occlusion, primitives-generated and timing queries.
Sync
GPU/CPU synchronisation fence objects.
TransformFeedback
Capture vertex shader outputs into buffers.
Minimal example
// Initialize the device with a function pointer loader (SDL3 shown)
easygl::Device device;
device.initialize(reinterpret_cast<easygl::GLGetProcAddressFn>(SDL_GL_GetProcAddress));
// Create a shader program from source strings directly
easygl::Program program(vertSrc, fragSrc);
// RAII buffer — destroyed automatically when it goes out of scope
easygl::Buffer vbo;
vbo.create();
vbo.bind(easygl::BufferTarget::Array);
vbo.set_data(easygl::BufferTarget::Array, vertices, sizeof(vertices));
// Render loop
device.set_clear_color(0.1f, 0.1f, 0.1f, 1.0f);
device.clear(easygl::ClearFlags::Color | easygl::ClearFlags::Depth);
program.use();
device.draw_arrays(easygl::PrimitiveType::Triangles, 0, 3);
Quick navigation
| Page | What it covers |
|---|---|
| Getting Started | CMake integration, first program, compile and run. |
| Architecture | How easy-gl, meta-gl and OpenGL relate to each other. |
| Ownership & RAII | Move semantics, generation tracking, context recovery. |
| Error Handling | Exceptions, validation, debug output. |
| Hello Triangle | Full SDL3 + easy-gl example with annotation. |