The repository had no licence at all, so every source was all-rights-reserved by default. Add the verbatim MIT text at LICENSE (Copyright (c) 2026 Martino Ferrari) and a two-line SPDX header to each of the 113 first-party sources -- 48 include/plot, 26 src, 10 adapters, 5 examples, 21 tests, 3 tools -- so the grant travels with each file rather than relying on the root document alone. Scripts keep their shebang on line 1; the SPDX lines follow it. Genuinely vendored code is untouched: third_party/stb_truetype.h carries no header of ours. src/render/embedded_mono_font.cpp is generated, so tools/fonts/gen_atlas.py emit() now writes the two lines into its header comment and the file was regenerated -- gen_atlas.py --check passes and the regeneration adds only those comment lines to the previously committed file. README's provenance section now states MIT and links LICENSE. No code, test or public API change.
42 lines
1.9 KiB
C++
42 lines
1.9 KiB
C++
// SPDX-License-Identifier: MIT
|
|
// SPDX-FileCopyrightText: 2026 Martino Ferrari
|
|
|
|
#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.
|
|
/// The above-baseline entries of `PLOT_GL_OPTIONAL_FUNCS` are resolved the same
|
|
/// way but never fail the load: a driver without them leaves those pointers
|
|
/// null, and callers reach them only behind `caps()`.
|
|
///
|
|
/// 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;
|
|
|
|
/// True once a `load()` has resolved every required entry point of the global
|
|
/// table. This is the gate superseding per-pointer null checks: while it is
|
|
/// false the table may be only partially populated (see load()), so no `gl*`
|
|
/// entry point may be called. The fallible handle constructors report
|
|
/// `ErrorCode::Unsupported` until it becomes true.
|
|
bool available() noexcept;
|
|
|
|
} // namespace plot::gl
|