src/gl.h: the OpenGL entry points the game calls, loaded through SDL (no libepoxy), as in smack-a-brother
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2b108ca729
commit
08ca87dded
2 files changed
+92
No files matched your search
+15
@@ -0,0 +1,15 @@
|
|||||||
|
#include "gl.h"
|
||||||
|
#include <SDL3/SDL_video.h>
|
||||||
|
|
||||||
|
Gl gl;
|
||||||
|
|
||||||
|
// Fills the table from the current context, leaving isLoaded false if any entry point is missing.
|
||||||
|
void gl_load()
|
||||||
|
{
|
||||||
|
gl.isLoaded = true;
|
||||||
|
#define GL_FUNCTION_LOAD(name) \
|
||||||
|
gl.name = (decltype(gl.name))SDL_GL_GetProcAddress("gl" #name); \
|
||||||
|
gl.isLoaded &= gl.name != nullptr;
|
||||||
|
GL_FUNCTIONS(GL_FUNCTION_LOAD)
|
||||||
|
#undef GL_FUNCTION_LOAD
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define GL_GLEXT_PROTOTYPES
|
||||||
|
#include <SDL3/SDL_opengl.h>
|
||||||
|
|
||||||
|
// The OpenGL entry points the game calls, loaded through SDL once a context exists.
|
||||||
|
#define GL_FUNCTIONS(X)\
|
||||||
|
X(ActiveTexture) \
|
||||||
|
X(AttachShader) \
|
||||||
|
X(BindFramebuffer) \
|
||||||
|
X(BindRenderbuffer) \
|
||||||
|
X(BindTexture) \
|
||||||
|
X(BlendEquation) \
|
||||||
|
X(BlendFuncSeparate) \
|
||||||
|
X(CheckFramebufferStatus) \
|
||||||
|
X(Clear) \
|
||||||
|
X(ClearColor) \
|
||||||
|
X(ClearDepth) \
|
||||||
|
X(CompileShader) \
|
||||||
|
X(CreateProgram) \
|
||||||
|
X(CreateShader) \
|
||||||
|
X(CullFace) \
|
||||||
|
X(DeleteFramebuffers) \
|
||||||
|
X(DeleteProgram) \
|
||||||
|
X(DeleteRenderbuffers) \
|
||||||
|
X(DeleteShader) \
|
||||||
|
X(DeleteTextures) \
|
||||||
|
X(DepthFunc) \
|
||||||
|
X(Disable) \
|
||||||
|
X(DisableVertexAttribArray) \
|
||||||
|
X(DrawElements) \
|
||||||
|
X(Enable) \
|
||||||
|
X(EnableVertexAttribArray) \
|
||||||
|
X(FramebufferRenderbuffer) \
|
||||||
|
X(FramebufferTexture2D) \
|
||||||
|
X(GenFramebuffers) \
|
||||||
|
X(GenRenderbuffers) \
|
||||||
|
X(GenTextures) \
|
||||||
|
X(GetAttribLocation) \
|
||||||
|
X(GetIntegerv) \
|
||||||
|
X(GetProgramInfoLog) \
|
||||||
|
X(GetProgramiv) \
|
||||||
|
X(GetRenderbufferParameteriv) \
|
||||||
|
X(GetShaderInfoLog) \
|
||||||
|
X(GetShaderiv) \
|
||||||
|
X(GetString) \
|
||||||
|
X(GetStringi) \
|
||||||
|
X(GetUniformLocation) \
|
||||||
|
X(LinkProgram) \
|
||||||
|
X(ReadPixels) \
|
||||||
|
X(RenderbufferStorage) \
|
||||||
|
X(ShaderSource) \
|
||||||
|
X(TexImage2D) \
|
||||||
|
X(TexParameteri) \
|
||||||
|
X(TexSubImage2D) \
|
||||||
|
X(Uniform1fv) \
|
||||||
|
X(Uniform1i) \
|
||||||
|
X(Uniform1iv) \
|
||||||
|
X(Uniform2fv) \
|
||||||
|
X(Uniform3fv) \
|
||||||
|
X(Uniform4fv) \
|
||||||
|
X(UniformMatrix4fv) \
|
||||||
|
X(UseProgram) \
|
||||||
|
X(VertexAttribPointer) \
|
||||||
|
X(Viewport)
|
||||||
|
|
||||||
|
struct Gl
|
||||||
|
{
|
||||||
|
#define GL_FUNCTION_DECLARE(name) decltype(&gl##name) name = nullptr;
|
||||||
|
GL_FUNCTIONS(GL_FUNCTION_DECLARE)
|
||||||
|
#undef GL_FUNCTION_DECLARE
|
||||||
|
bool isLoaded = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern Gl gl;
|
||||||
|
|
||||||
|
void gl_load();
|
||||||
Reference in new issue
Block a user