Orrery
A GPU-accelerated N-body gravitational simulator
Loading...
Searching...
No Matches
gl_api.hpp File Reference

The OpenGL entry points this renderer uses, and only those. More...

#include <cstddef>
#include <cstdint>

Go to the source code of this file.

Classes

struct  orrery::viz::GlFunctions
 The entry points, as the pointers the driver returns. More...

Typedefs

using orrery::viz::GlEnum = std::uint32_t
 The subset of the OpenGL type system these entry points need.
using orrery::viz::GlBitfield = std::uint32_t
using orrery::viz::GlUint = std::uint32_t
using orrery::viz::GlInt = std::int32_t
using orrery::viz::GlSizei = std::int32_t
using orrery::viz::GlBoolean = std::uint8_t
using orrery::viz::GlUbyte = std::uint8_t
using orrery::viz::GlFloat = float
using orrery::viz::GlChar = char
using orrery::viz::GlSizeiptr = std::ptrdiff_t
using orrery::viz::GlIntptr = std::ptrdiff_t
using orrery::viz::GlProcedureLoader = void (*(*)(const char*))()
 How a function is fetched from the driver.

Functions

GlFunctions orrery::viz::load_gl_functions (GlProcedureLoader loader)
 Resolve every entry point above, or say which one was missing.

Variables

constexpr GlEnum orrery::viz::kGlFalse = 0
constexpr GlEnum orrery::viz::kGlOne = 1
constexpr GlEnum orrery::viz::kGlPoints = 0x0000
constexpr GlEnum orrery::viz::kGlTriangles = 0x0004
constexpr GlEnum orrery::viz::kGlNoError = 0
constexpr GlEnum orrery::viz::kGlVendor = 0x1F00
constexpr GlEnum orrery::viz::kGlRenderer = 0x1F01
constexpr GlEnum orrery::viz::kGlVersion = 0x1F02
constexpr GlEnum orrery::viz::kGlFloatType = 0x1406
constexpr GlBitfield orrery::viz::kGlColorBufferBit = 0x00004000
constexpr GlEnum orrery::viz::kGlDepthTest = 0x0B71
constexpr GlEnum orrery::viz::kGlBlend = 0x0BE2
constexpr GlEnum orrery::viz::kGlProgramPointSize = 0x8642
constexpr GlEnum orrery::viz::kGlFramebufferSrgb = 0x8DB9
constexpr GlEnum orrery::viz::kGlArrayBuffer = 0x8892
constexpr GlEnum orrery::viz::kGlStreamDraw = 0x88E0
constexpr GlEnum orrery::viz::kGlVertexShader = 0x8B31
constexpr GlEnum orrery::viz::kGlFragmentShader = 0x8B30
constexpr GlEnum orrery::viz::kGlCompileStatus = 0x8B81
constexpr GlEnum orrery::viz::kGlLinkStatus = 0x8B82
constexpr GlEnum orrery::viz::kGlInfoLogLength = 0x8B84
constexpr GlEnum orrery::viz::kGlTexture2d = 0x0DE1
constexpr GlEnum orrery::viz::kGlTexture0 = 0x84C0
constexpr GlEnum orrery::viz::kGlRgb = 0x1907
constexpr GlEnum orrery::viz::kGlRgba = 0x1908
constexpr GlEnum orrery::viz::kGlRgba16f = 0x881A
constexpr GlEnum orrery::viz::kGlTextureMinFilter = 0x2801
constexpr GlEnum orrery::viz::kGlTextureMagFilter = 0x2800
constexpr GlEnum orrery::viz::kGlTextureWrapS = 0x2802
constexpr GlEnum orrery::viz::kGlTextureWrapT = 0x2803
constexpr GlEnum orrery::viz::kGlNearest = 0x2600
constexpr GlEnum orrery::viz::kGlClampToEdge = 0x812F
constexpr GlEnum orrery::viz::kGlFramebuffer = 0x8D40
constexpr GlEnum orrery::viz::kGlColorAttachment0 = 0x8CE0
constexpr GlEnum orrery::viz::kGlFramebufferComplete = 0x8CD5

Detailed Description

The OpenGL entry points this renderer uses, and only those.

On every desktop platform the OpenGL library exports the functions of version 1.1 and nothing later. Everything a modern renderer needs, buffers, shaders, vertex arrays, framebuffers, is fetched at run time from the driver by name. Something has to do that fetching.

The usual something is a generated loader, glad or GLEW, which declares every function in every version and extension of the API and resolves them all. This file does it by hand for the thirty-nine entry points the renderer actually calls. The reason is proportion: a generated loader is several thousand lines of code that nobody in this repository will read, added as a dependency or vendored as a generated artefact, to save writing the list below. ADR-0035 records the choice and what it costs, which is that adding a call to a function not in this list is a two-line edit rather than none.

The declarations are the API's own, taken from the OpenGL registry. The types and the constants have to match the driver's exactly, because nothing checks them: a wrong constant is a silently wrong render and a wrong signature is undefined behaviour. Each constant is therefore written as the hexadecimal value the registry gives it rather than derived from anything.

Nothing here is included by anything above the renderer.

Typedef Documentation

◆ GlEnum

using orrery::viz::GlEnum = std::uint32_t

The subset of the OpenGL type system these entry points need.

Fixed-width where the API fixes the width, which it does for all of these: GLint is 32 bits on every platform OpenGL runs on, whatever int happens to be, and spelling it as int would be right by accident.

◆ GlProcedureLoader

using orrery::viz::GlProcedureLoader = void (*(*)(const char*))()

How a function is fetched from the driver.

Taken as a parameter rather than called directly, because the answer comes from the window system library and this file has no business knowing which one is in use.

Function Documentation

◆ load_gl_functions()

GlFunctions orrery::viz::load_gl_functions ( GlProcedureLoader loader)
nodiscard

Resolve every entry point above, or say which one was missing.

Throws std::runtime_error naming the first function the driver did not provide. That is a setup boundary and the only useful response to it: a renderer that carried on with a null pointer would crash inside the driver with no indication of which call it was.