feat(gl): dependency-free GL loader, RAII handles, caps probe, headless EGL harness

This commit is contained in:
Martino Ferrari committed 2026-09-27 21:07:36 +02:00
1 parent ed71719df7
commit 258caa38a7
11 files changed
+1458 -1

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
#pragma once
#include <plot/gl/api.hpp>
namespace plot::gl {
/// Entry point resolver supplied by the caller, normally the *GetProcAddress
/// of the API that owns the current context: `eglGetProcAddress`,
/// `glXGetProcAddressARB` or `wglGetProcAddress`.
using ProcLoader = void* (*)(const char*);
/// Resolves every entry point of `PLOT_GL_FUNCS` (see api.hpp) into the global
/// table declared there, so the rest of the library can call `gl*` directly.
///
/// Returns false when any required name cannot be found; entries that did
/// resolve keep their pointers, so a failed load() never breaks a table that
/// was already usable. `loader` is consulted first; when it is null, or returns
/// null for a name, the fallback is `dlsym(RTLD_DEFAULT, name)` and then
/// `dlopen("libGL.so.1")` + `dlsym`. The fallback makes the library usable
/// without a caller-supplied resolver, but only a context-aware resolver is
/// guaranteed to return pointers valid for the *current* context — pass one
/// whenever a context is current.
///
/// A load() attempt invalidates the caps() cache. The table is process-global
/// and is not synchronised, so call from the thread that owns the current
/// context.
bool load(ProcLoader loader = nullptr) noexcept;
} // namespace plot::gl