Files
scuffedcraft/src/pltf/win32/gl_funcs.c
2026-07-03 22:07:03 +03:00

34 lines
992 B
C

#include "../gl_funcs.h"
#include "log.h"
#include "internal.h"
#define X(type, name) \
type name = NULL
PLTF_GL_FUNCS(X)
#undef X
#define X(type, name) \
name = (type) pltf_gl_function_load(#name)
void* pltf_gl_function_load(const char* name) {
void* gl_func = (void*) wglGetProcAddress(name);
if (gl_func == NULL || gl_func == (void*) 1 || gl_func == (void*) 2 || gl_func == (void*) 3 || gl_func == (void*) -1) {
void* gl32_func = (void*) GetProcAddress(opengl_module, name);
if (gl32_func == NULL || gl32_func == (void*) 1 || gl32_func == (void*) 2 || gl32_func == (void*) 3 || gl32_func == (void*) -1) {
LOG_ERRORF("wglGetProcAddress failed to load gl function %s. Returned %p\n", name, gl_func);
LOG_ERRORF("GetProcAddress failed to load gl function %s. Returned %p\n", name, gl32_func);
return NULL;
}
return gl32_func;
}
return gl_func;
}
void pltf_gl_funcs_load() {
PLTF_GL_FUNCS(X)
}