Orrery
A GPU-accelerated N-body gravitational simulator
Loading...
Searching...
No Matches
gl_api.hpp
Go to the documentation of this file.
1#pragma once
2
27
28#include <cstddef>
29#include <cstdint>
30
31namespace orrery::viz {
32
38using GlEnum = std::uint32_t;
39using GlBitfield = std::uint32_t;
40using GlUint = std::uint32_t;
41using GlInt = std::int32_t;
42using GlSizei = std::int32_t;
43using GlBoolean = std::uint8_t;
44using GlUbyte = std::uint8_t;
45using GlFloat = float;
46using GlChar = char;
47using GlSizeiptr = std::ptrdiff_t;
48using GlIntptr = std::ptrdiff_t;
49
50inline constexpr GlEnum kGlFalse = 0;
51inline constexpr GlEnum kGlOne = 1;
52
53inline constexpr GlEnum kGlPoints = 0x0000;
54inline constexpr GlEnum kGlTriangles = 0x0004;
55inline constexpr GlEnum kGlNoError = 0;
56inline constexpr GlEnum kGlVendor = 0x1F00;
57inline constexpr GlEnum kGlRenderer = 0x1F01;
58inline constexpr GlEnum kGlVersion = 0x1F02;
59inline constexpr GlEnum kGlFloatType = 0x1406;
60
61inline constexpr GlBitfield kGlColorBufferBit = 0x00004000;
62inline constexpr GlEnum kGlDepthTest = 0x0B71;
63inline constexpr GlEnum kGlBlend = 0x0BE2;
64inline constexpr GlEnum kGlProgramPointSize = 0x8642;
65inline constexpr GlEnum kGlFramebufferSrgb = 0x8DB9;
66
67inline constexpr GlEnum kGlArrayBuffer = 0x8892;
68inline constexpr GlEnum kGlStreamDraw = 0x88E0;
69
70inline constexpr GlEnum kGlVertexShader = 0x8B31;
71inline constexpr GlEnum kGlFragmentShader = 0x8B30;
72inline constexpr GlEnum kGlCompileStatus = 0x8B81;
73inline constexpr GlEnum kGlLinkStatus = 0x8B82;
74inline constexpr GlEnum kGlInfoLogLength = 0x8B84;
75
76inline constexpr GlEnum kGlTexture2d = 0x0DE1;
77inline constexpr GlEnum kGlTexture0 = 0x84C0;
78inline constexpr GlEnum kGlRgb = 0x1907;
79inline constexpr GlEnum kGlRgba = 0x1908;
80inline constexpr GlEnum kGlRgba16f = 0x881A;
81inline constexpr GlEnum kGlTextureMinFilter = 0x2801;
82inline constexpr GlEnum kGlTextureMagFilter = 0x2800;
83inline constexpr GlEnum kGlTextureWrapS = 0x2802;
84inline constexpr GlEnum kGlTextureWrapT = 0x2803;
85inline constexpr GlEnum kGlNearest = 0x2600;
86inline constexpr GlEnum kGlClampToEdge = 0x812F;
87
88inline constexpr GlEnum kGlFramebuffer = 0x8D40;
89inline constexpr GlEnum kGlColorAttachment0 = 0x8CE0;
90inline constexpr GlEnum kGlFramebufferComplete = 0x8CD5;
91
97using GlProcedureLoader = void (*(*)(const char*))();
98
107 void (*viewport)(GlInt, GlInt, GlSizei, GlSizei) = nullptr;
108 void (*clear_colour)(GlFloat, GlFloat, GlFloat, GlFloat) = nullptr;
109 void (*clear)(GlBitfield) = nullptr;
110 void (*enable)(GlEnum) = nullptr;
111 void (*disable)(GlEnum) = nullptr;
112 void (*blend_func)(GlEnum, GlEnum) = nullptr;
113 void (*draw_arrays)(GlEnum, GlInt, GlSizei) = nullptr;
114 void (*read_pixels)(GlInt, GlInt, GlSizei, GlSizei, GlEnum, GlEnum, void*) = nullptr;
115 GlEnum (*get_error)() = nullptr;
116 const GlUbyte* (*get_string)(GlEnum) = nullptr;
117
118 void (*gen_vertex_arrays)(GlSizei, GlUint*) = nullptr;
119 void (*bind_vertex_array)(GlUint) = nullptr;
120 void (*delete_vertex_arrays)(GlSizei, const GlUint*) = nullptr;
121
122 void (*gen_buffers)(GlSizei, GlUint*) = nullptr;
123 void (*bind_buffer)(GlEnum, GlUint) = nullptr;
124 void (*buffer_data)(GlEnum, GlSizeiptr, const void*, GlEnum) = nullptr;
125 void (*buffer_sub_data)(GlEnum, GlIntptr, GlSizeiptr, const void*) = nullptr;
126 void (*delete_buffers)(GlSizei, const GlUint*) = nullptr;
127
128 void (*enable_vertex_attrib_array)(GlUint) = nullptr;
129 void (*vertex_attrib_pointer)(GlUint, GlInt, GlEnum, GlBoolean, GlSizei, const void*) = nullptr;
130
131 GlUint (*create_shader)(GlEnum) = nullptr;
132 void (*shader_source)(GlUint, GlSizei, const GlChar* const*, const GlInt*) = nullptr;
133 void (*compile_shader)(GlUint) = nullptr;
134 void (*get_shader_iv)(GlUint, GlEnum, GlInt*) = nullptr;
135 void (*get_shader_info_log)(GlUint, GlSizei, GlSizei*, GlChar*) = nullptr;
136 void (*delete_shader)(GlUint) = nullptr;
137
138 GlUint (*create_program)() = nullptr;
139 void (*attach_shader)(GlUint, GlUint) = nullptr;
140 void (*link_program)(GlUint) = nullptr;
141 void (*get_program_iv)(GlUint, GlEnum, GlInt*) = nullptr;
142 void (*get_program_info_log)(GlUint, GlSizei, GlSizei*, GlChar*) = nullptr;
143 void (*use_program)(GlUint) = nullptr;
144 void (*delete_program)(GlUint) = nullptr;
145
146 GlInt (*get_uniform_location)(GlUint, const GlChar*) = nullptr;
147 void (*uniform_matrix4fv)(GlInt, GlSizei, GlBoolean, const GlFloat*) = nullptr;
148 void (*uniform1f)(GlInt, GlFloat) = nullptr;
149 void (*uniform1i)(GlInt, GlInt) = nullptr;
150 void (*uniform3f)(GlInt, GlFloat, GlFloat, GlFloat) = nullptr;
151
152 void (*gen_textures)(GlSizei, GlUint*) = nullptr;
153 void (*bind_texture)(GlEnum, GlUint) = nullptr;
154 void (*active_texture)(GlEnum) = nullptr;
155 void (*tex_image_2d)(GlEnum, GlInt, GlInt, GlSizei, GlSizei, GlInt, GlEnum, GlEnum,
156 const void*) = nullptr;
157 void (*tex_parameter_i)(GlEnum, GlEnum, GlInt) = nullptr;
158 void (*delete_textures)(GlSizei, const GlUint*) = nullptr;
159
160 void (*gen_framebuffers)(GlSizei, GlUint*) = nullptr;
161 void (*bind_framebuffer)(GlEnum, GlUint) = nullptr;
162 void (*framebuffer_texture_2d)(GlEnum, GlEnum, GlEnum, GlUint, GlInt) = nullptr;
163 GlEnum (*check_framebuffer_status)(GlEnum) = nullptr;
164 void (*delete_framebuffers)(GlSizei, const GlUint*) = nullptr;
165};
166
174
175} // namespace orrery::viz
GlFunctions load_gl_functions(GlProcedureLoader loader)
Resolve every entry point above, or say which one was missing.
std::uint32_t GlEnum
The subset of the OpenGL type system these entry points need.
Definition gl_api.hpp:38
void(*(*)(const char *))() GlProcedureLoader
How a function is fetched from the driver.
Definition gl_api.hpp:97
The entry points, as the pointers the driver returns.
Definition gl_api.hpp:106