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

Layer diagram

OpenGL / OpenGL ES
meta-gl — procedural type-safe wrappers, enum classes, typed handles, std::span
easy-gl — OOP RAII classes, move-only ownership, convenience methods
Your application

Resource 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

PageWhat it covers
Getting StartedCMake integration, first program, compile and run.
ArchitectureHow easy-gl, meta-gl and OpenGL relate to each other.
Ownership & RAIIMove semantics, generation tracking, context recovery.
Error HandlingExceptions, validation, debug output.
Hello TriangleFull SDL3 + easy-gl example with annotation.