Types Reference
Types are declared in include/metagl/Types.hpp.
meta-gl re-exports the standard OpenGL ES primitive types from
GLES3/gl32.h into the metagl namespace so
calling code does not need to include any GL headers directly.
GL Primitive Types
These are simple using declarations that bring the GL types into metagl::.
| metagl type | Underlying type | Typical use |
|---|---|---|
GLbitfield | unsigned int | Bitfield parameters (e.g. glClear) |
GLboolean | unsigned char | Boolean return values |
GLbyte | signed char | 8-bit signed vertex data |
GLchar | char | Shader source / info log strings |
GLclampf | float | Clamped [0,1] float parameters |
GLenum | unsigned int | Base type for all GL enumerations |
GLfixed | int (16.16 fixed) | Legacy fixed-point values |
GLfloat | float | Most numeric GL parameters |
GLhalf | unsigned short | 16-bit IEEE half-float |
GLint | int | General integer parameters |
GLint64 | long long | 64-bit state queries (ES3+) |
GLintptr | ptrdiff_t | Buffer byte offsets |
GLshort | short | 16-bit signed vertex data |
GLsizei | int | Non-negative sizes and counts |
GLsizeiptr | ptrdiff_t | Buffer sizes in bytes |
GLsync | struct __GLsync* | Fence sync handle |
GLubyte | unsigned char | String returns, colour components |
GLuint | unsigned int | Object names (textures, buffers, etc.) |
GLuint64 | unsigned long long | Timeout values, 64-bit queries |
GLushort | unsigned short | 16-bit unsigned index data |
GLvoid | void | Alias for void |
GLDEBUGPROC | function pointer | Debug message callback type |
GetProcAddress Type
// In Types.hpp: using GlGetProcAddressFn = void* (*)(const char* name); // In Loader.hpp (alias for API ergonomics): using GetProcAddress = GlGetProcAddressFn;
This is the type that must be passed to metagl::Initialize().
Any callable that returns a function pointer given a GL function name satisfies this type.
Lightweight Handle Structs
meta-gl defines thin wrapper structs around raw GLuint names to prevent
accidentally passing a texture handle where a buffer handle is expected.
These structs own nothing — they contain no destructor and no reference counting.
namespace metagl { struct TextureId { GLuint value{}; }; struct BufferId { GLuint value{}; }; struct ShaderId { GLuint value{}; }; struct ProgramId { GLuint value{}; }; struct FramebufferId { GLuint value{}; }; struct RenderbufferId { GLuint value{}; }; struct VertexArrayId { GLuint value{}; }; struct SamplerId { GLuint value{}; }; } // namespace metagl
Usage
// Create a texture and wrap it in a typed handle: GLuint raw; metagl::glGenTextures(1, &raw); metagl::TextureId tex{ raw }; // Now tex.value carries the GLuint. It is just data — no lifetime management: metagl::glBindTexture(metagl::TextureTarget::Texture2D, tex.value); // When you're done, delete explicitly (as in raw OpenGL): metagl::glDeleteTextures(1, &tex.value); // RAII deletion belongs in easy-gl, not here.
Why Handle Structs Instead of GLuint?
Without handles
GLuint tex = 0, buf = 0; glGenTextures(1, &tex); glGenBuffers(1, &buf); // Oops — compiles fine: glBindTexture(GL_TEXTURE_2D, buf);
With handles
TextureId tex; BufferId buf; metagl::glGenTextures(1, &tex.value); metagl::glGenBuffers(1, &buf.value); // type system helps catch swaps
EnumNames.hpp
include/metagl/EnumNames.hpp contains generated to_string()
overloads for every enumerator in every enum class.
The return type is std::string_view.
Unknown values return "?".
#include <metagl/EnumNames.hpp> metagl::BufferTarget t = metagl::BufferTarget::Array; std::string_view name = metagl::to_string(t); // name == "Array" metagl::ShaderType st = metagl::ShaderType::Vertex; std::string_view sname = metagl::to_string(st); // sname == "Vertex"
This is used by the debug logger to print human-readable argument names instead of raw integer values.