refactor: nuke gl query functions to remove libdl dependence in the renderer

This commit is contained in:
Tropical 2026-04-10 15:40:21 -05:00
parent 41437bb999
commit 1628e08748
4 changed files with 0 additions and 95 deletions

View file

@ -1406,44 +1406,6 @@ void glDeleteTextures_4J(int n, const unsigned int* textures) {
::glDeleteTextures(n, textures);
}
void glBeginQuery_4J_Helper(unsigned int target, unsigned int id) {
typedef void (*PFNGLBEGINQUERYPROC)(unsigned int, unsigned int);
static PFNGLBEGINQUERYPROC fn =
(PFNGLBEGINQUERYPROC)dlsym(RTLD_DEFAULT, "glBeginQuery");
if (fn) fn(target, id);
}
void glEndQuery_4J_Helper(unsigned int target) {
typedef void (*PFNGLENDQUERYPROC)(unsigned int);
static PFNGLENDQUERYPROC fn =
(PFNGLENDQUERYPROC)dlsym(RTLD_DEFAULT, "glEndQuery");
if (fn) fn(target);
}
void glGenQueries_4J_Helper(unsigned int* id) {
#ifdef GLES
glGenQueries(1, id);
#else
typedef void (*PFNGLGENQUERIESPROC)(int, unsigned int*);
static PFNGLGENQUERIESPROC fn =
(PFNGLGENQUERIESPROC)dlsym(RTLD_DEFAULT, "glGenQueries");
if (fn) fn(1, id);
#endif
}
void glGetQueryObjectu_4J_Helper(unsigned int id, unsigned int pname,
unsigned int* val) {
#ifdef GLES
glGetQueryObjectuiv(id, pname, val);
#else
typedef void (*PFNGLGETQUERYOBJECTUIVPROC)(unsigned int, unsigned int,
unsigned int*);
static PFNGLGETQUERYOBJECTUIVPROC fn =
(PFNGLGETQUERYOBJECTUIVPROC)dlsym(RTLD_DEFAULT, "glGetQueryObjectuiv");
if (fn) fn(id, pname, val);
#endif
}
// c hooks
#undef glFogfv
#undef glLightfv
@ -1578,54 +1540,9 @@ void glVertexPointer_4J(int, int, FloatBuffer*) {}
void glEndList_4J(int) {}
void glTexGen_4J(int, int, FloatBuffer*) {}
#include <dlfcn.h>
#include <stdio.h>
#include <string.h>
static PFNGLGENQUERIESARBPROC _glGenQueriesARB = nullptr;
static PFNGLBEGINQUERYARBPROC _glBeginQueryARB = nullptr;
static PFNGLENDQUERYARBPROC _glEndQueryARB = nullptr;
static PFNGLGETQUERYOBJECTUIVARBPROC _glGetQueryObjectuivARB = nullptr;
static bool _queriesInitialized = false;
static void initQueryFuncs() {
if (_queriesInitialized) return;
_queriesInitialized = true;
_glGenQueriesARB =
(PFNGLGENQUERIESARBPROC)dlsym(RTLD_DEFAULT, "glGenQueriesARB");
_glBeginQueryARB =
(PFNGLBEGINQUERYARBPROC)dlsym(RTLD_DEFAULT, "glBeginQueryARB");
_glEndQueryARB = (PFNGLENDQUERYARBPROC)dlsym(RTLD_DEFAULT, "glEndQueryARB");
_glGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC)dlsym(
RTLD_DEFAULT, "glGetQueryObjectuivARB");
}
void glGenQueriesARB_4J(IntBuffer* buf) {
initQueryFuncs();
if (_glGenQueriesARB && buf) {
int n = buf->limit() - buf->position();
if (n > 0) _glGenQueriesARB(n, (GLuint*)getIntPtr(buf));
}
}
void glBeginQueryARB_4J(int target, int id) {
initQueryFuncs();
if (_glBeginQueryARB) _glBeginQueryARB((GLenum)target, (GLuint)id);
}
void glEndQueryARB_4J(int target) {
initQueryFuncs();
if (_glEndQueryARB) _glEndQueryARB((GLenum)target);
}
void glGetQueryObjectuARB_4J(int id, int pname, IntBuffer* params) {
initQueryFuncs();
if (_glGetQueryObjectuivARB && params)
// LWJGL does not change limits/positions during these calls, it
// reads/writes exactly at pointer!!
_glGetQueryObjectuivARB((GLuint)id, (GLenum)pname,
(GLuint*)getIntPtr(params));
}
void glGetFloat(int pname, FloatBuffer* params) {
glGetFloat_4J(pname, params);
}

View file

@ -574,12 +574,6 @@ inline void glReadPixels_4J(int x, int y, int width, int height, int format,
::glReadPixels(x, y, width, height, (unsigned int)format,
(unsigned int)type, pixels->getBuffer());
}
void glBeginQuery_4J_Helper(unsigned int target, unsigned int id);
void glEndQuery_4J_Helper(unsigned int target);
void glGenQueries_4J_Helper(unsigned int* id);
void glGetQueryObjectu_4J_Helper(unsigned int id, unsigned int pname,
unsigned int* val);
// redirect the functions to my own implementation, no more 2.1 funcs
#define glGenTextures(...) glGenTextures_4J(__VA_ARGS__)
#define glDeleteTextures(...) glDeleteTextures_4J(__VA_ARGS__)

View file

@ -1,5 +1,4 @@
platform_renderer_gl_dependencies = [
dependency('dl'),
dependency('sdl2'),
dependency('glm'),
dependency('stb'),

View file

@ -34,11 +34,6 @@ void glEndList_4J(int vertexCount = 0);
void glTexImage2D(int, int, int, int, int, int, int, int, ByteBuffer*);
void glCallLists(IntBuffer*);
void glGenQueriesARB(IntBuffer*);
void glBeginQueryARB(int, int);
void glEndQueryARB(int);
void glGetQueryObjectuARB(int, int, IntBuffer*);
void glReadPixels(int, int, int, int, int, int, ByteBuffer*);
class GL11 {
public: