254 lines
11 KiB
C++
Raw Normal View History

2022-06-30 19:53:32 -04:00
#include <GLES/gl.h>
2024-10-05 23:52:44 -04:00
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>
2022-06-30 19:53:32 -04:00
2024-10-05 23:52:44 -04:00
#include <libreborn/libreborn.h>
// Load GL Function
unsigned int media_context_id = 0;
#define GL_FUNC(name, return_type, args) \
typedef return_type (*real_##name##_t)args; \
__attribute__((__unused__)) static real_##name##_t real_##name() { \
static real_##name##_t func = nullptr; \
static unsigned int old_context = 0; \
if (!func || old_context != media_context_id) { \
old_context = media_context_id; \
func = (real_##name##_t) glfwGetProcAddress(#name); \
if (!func) { \
ERR("Error Resolving OpenGL Function: " #name); \
} \
} \
return func; \
}
2022-06-30 19:53:32 -04:00
2024-10-09 10:43:37 -04:00
// Passthrough Functions
GL_FUNC(glFogfv, void, (GLenum pname, const GLfloat *params))
2024-10-20 01:19:08 -04:00
void media_glFogfv(const GLenum pname, const GLfloat *params) {
2022-06-30 19:53:32 -04:00
real_glFogfv()(pname, params);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glVertexPointer, void, (GLint size, GLenum type, GLsizei stride, const void *pointer))
2024-10-20 01:19:08 -04:00
void media_glVertexPointer(const GLint size, const GLenum type, const GLsizei stride, const void *pointer) {
2022-06-30 19:53:32 -04:00
real_glVertexPointer()(size, type, stride, pointer);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glLineWidth, void, (GLfloat width))
2024-10-20 01:19:08 -04:00
void media_glLineWidth(const GLfloat width) {
2022-06-30 19:53:32 -04:00
real_glLineWidth()(width);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glBlendFunc, void, (GLenum sfactor, GLenum dfactor))
2024-10-20 01:19:08 -04:00
void media_glBlendFunc(const GLenum sfactor, const GLenum dfactor) {
2022-06-30 19:53:32 -04:00
real_glBlendFunc()(sfactor, dfactor);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glDrawArrays, void, (GLenum mode, GLint first, GLsizei count))
2024-10-20 01:19:08 -04:00
void media_glDrawArrays(const GLenum mode, const GLint first, const GLsizei count) {
2022-06-30 19:53:32 -04:00
real_glDrawArrays()(mode, first, count);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glColor4f, void, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha))
2024-10-20 01:19:08 -04:00
void media_glColor4f(const GLfloat red, const GLfloat green, const GLfloat blue, const GLfloat alpha) {
2022-06-30 19:53:32 -04:00
real_glColor4f()(red, green, blue, alpha);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glClear, void, (GLbitfield mask))
2024-10-20 01:19:08 -04:00
void media_glClear(const GLbitfield mask) {
2022-06-30 19:53:32 -04:00
real_glClear()(mask);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glBufferData, void, (GLenum target, GLsizeiptr size, const void *data, GLenum usage))
2024-10-20 01:19:08 -04:00
void media_glBufferData(const GLenum target, const GLsizeiptr size, const void *data, const GLenum usage) {
2022-06-30 19:53:32 -04:00
real_glBufferData()(target, size, data, usage);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glBufferSubData, void, (GLenum target, GLintptr offset, GLsizeiptr size, const void *data))
2024-10-20 01:19:08 -04:00
void media_glBufferSubData(const GLenum target, const GLintptr offset, const GLsizeiptr size, const void *data) {
2024-10-05 23:52:44 -04:00
real_glBufferSubData()(target, offset, size, data);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glFogi, void, (GLenum pname, GLint param))
2024-10-20 01:19:08 -04:00
void media_glFogx(const GLenum pname, const GLfixed param) {
2024-10-05 23:52:44 -04:00
real_glFogi()(pname, param);
2022-06-30 19:53:32 -04:00
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glFogf, void, (GLenum pname, GLfloat param))
2024-10-20 01:19:08 -04:00
void media_glFogf(const GLenum pname, const GLfloat param) {
2022-06-30 19:53:32 -04:00
real_glFogf()(pname, param);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glMatrixMode, void, (GLenum mode))
2024-10-20 01:19:08 -04:00
void media_glMatrixMode(const GLenum mode) {
2022-06-30 19:53:32 -04:00
real_glMatrixMode()(mode);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glColorPointer, void, (GLint size, GLenum type, GLsizei stride, const void *pointer))
2024-10-20 01:19:08 -04:00
void media_glColorPointer(const GLint size, const GLenum type, const GLsizei stride, const void *pointer) {
2022-06-30 19:53:32 -04:00
real_glColorPointer()(size, type, stride, pointer);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glScissor, void, (GLint x, GLint y, GLsizei width, GLsizei height))
2024-10-20 01:19:08 -04:00
void media_glScissor(const GLint x, const GLint y, const GLsizei width, const GLsizei height) {
2022-06-30 19:53:32 -04:00
real_glScissor()(x, y, width, height);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glTexParameteri, void, (GLenum target, GLenum pname, GLint param))
2024-10-20 01:19:08 -04:00
void media_glTexParameteri(const GLenum target, const GLenum pname, const GLint param) {
2022-06-30 19:53:32 -04:00
real_glTexParameteri()(target, pname, param);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glTexImage2D, void, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels))
2024-10-20 01:19:08 -04:00
void media_glTexImage2D(const GLenum target, const GLint level, const GLint internalformat, const GLsizei width, const GLsizei height, const GLint border, const GLenum format, const GLenum type, const void *pixels) {
2022-06-30 19:53:32 -04:00
real_glTexImage2D()(target, level, internalformat, width, height, border, format, type, pixels);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glEnable, void, (GLenum cap))
2024-10-20 01:19:08 -04:00
void media_glEnable(const GLenum cap) {
2022-06-30 19:53:32 -04:00
real_glEnable()(cap);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glEnableClientState, void, (GLenum array))
2024-10-20 01:19:08 -04:00
void media_glEnableClientState(const GLenum array) {
2022-06-30 19:53:32 -04:00
real_glEnableClientState()(array);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glPolygonOffset, void, (GLfloat factor, GLfloat units))
2024-10-20 01:19:08 -04:00
void media_glPolygonOffset(const GLfloat factor, const GLfloat units) {
2022-06-30 19:53:32 -04:00
real_glPolygonOffset()(factor, units);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glDisableClientState, void, (GLenum array))
2024-10-20 01:19:08 -04:00
void media_glDisableClientState(const GLenum array) {
2022-06-30 19:53:32 -04:00
real_glDisableClientState()(array);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glDepthRange, void, (GLclampd near, GLclampd far))
2024-10-20 01:19:08 -04:00
void media_glDepthRangef(const GLclampf near, const GLclampf far) {
2024-10-05 23:52:44 -04:00
real_glDepthRange()(near, far);
2022-06-30 19:53:32 -04:00
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glDepthFunc, void, (GLenum func))
2024-10-20 01:19:08 -04:00
void media_glDepthFunc(const GLenum func) {
2022-06-30 19:53:32 -04:00
real_glDepthFunc()(func);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glBindBuffer, void, (GLenum target, GLuint buffer))
2024-10-20 01:19:08 -04:00
void media_glBindBuffer(const GLenum target, const GLuint buffer) {
2022-06-30 19:53:32 -04:00
real_glBindBuffer()(target, buffer);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glClearColor, void, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha))
2024-10-20 01:19:08 -04:00
void media_glClearColor(const GLclampf red, const GLclampf green, const GLclampf blue, const GLclampf alpha) {
2022-06-30 19:53:32 -04:00
real_glClearColor()(red, green, blue, alpha);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glPopMatrix, void, ())
2024-10-20 01:19:08 -04:00
void media_glPopMatrix() {
2022-06-30 19:53:32 -04:00
real_glPopMatrix()();
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glLoadIdentity, void, ())
2024-10-20 01:19:08 -04:00
void media_glLoadIdentity() {
2022-06-30 19:53:32 -04:00
real_glLoadIdentity()();
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glScalef, void, (GLfloat x, GLfloat y, GLfloat z))
2024-10-20 01:19:08 -04:00
void media_glScalef(const GLfloat x, const GLfloat y, const GLfloat z) {
2022-06-30 19:53:32 -04:00
real_glScalef()(x, y, z);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glPushMatrix, void, ())
2024-10-20 01:19:08 -04:00
void media_glPushMatrix() {
2022-06-30 19:53:32 -04:00
real_glPushMatrix()();
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glDepthMask, void, (GLboolean flag))
2024-10-20 01:19:08 -04:00
void media_glDepthMask(const GLboolean flag) {
2022-06-30 19:53:32 -04:00
real_glDepthMask()(flag);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glHint, void, (GLenum target, GLenum mode))
2024-10-20 01:19:08 -04:00
void media_glHint(const GLenum target, const GLenum mode) {
2022-06-30 19:53:32 -04:00
real_glHint()(target, mode);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glMultMatrixf, void, (const GLfloat *m))
2024-10-20 01:19:08 -04:00
void media_glMultMatrixf(const GLfloat *m) {
2022-06-30 19:53:32 -04:00
real_glMultMatrixf()(m);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glTexCoordPointer, void, (GLint size, GLenum type, GLsizei stride, const void *pointer))
2024-10-20 01:19:08 -04:00
void media_glTexCoordPointer(const GLint size, const GLenum type, const GLsizei stride, const void *pointer) {
2022-06-30 19:53:32 -04:00
real_glTexCoordPointer()(size, type, stride, pointer);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glDeleteBuffers, void, (GLsizei n, const GLuint *buffers))
2024-10-20 01:19:08 -04:00
void media_glDeleteBuffers(const GLsizei n, const GLuint *buffers) {
2022-06-30 19:53:32 -04:00
real_glDeleteBuffers()(n, buffers);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glColorMask, void, (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha))
2024-10-20 01:19:08 -04:00
void media_glColorMask(const GLboolean red, const GLboolean green, const GLboolean blue, const GLboolean alpha) {
2022-06-30 19:53:32 -04:00
real_glColorMask()(red, green, blue, alpha);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glTexSubImage2D, void, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels))
2024-10-20 01:19:08 -04:00
void media_glTexSubImage2D(const GLenum target, const GLint level, const GLint xoffset, const GLint yoffset, const GLsizei width, const GLsizei height, const GLenum format, const GLenum type, const void *pixels) {
2022-06-30 19:53:32 -04:00
real_glTexSubImage2D()(target, level, xoffset, yoffset, width, height, format, type, pixels);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glGenTextures, void, (GLsizei n, GLuint *textures))
2024-10-20 01:19:08 -04:00
void media_glGenTextures(const GLsizei n, GLuint *textures) {
2022-06-30 19:53:32 -04:00
real_glGenTextures()(n, textures);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glDeleteTextures, void, (GLsizei n, const GLuint *textures))
2024-10-20 01:19:08 -04:00
void media_glDeleteTextures(const GLsizei n, const GLuint *textures) {
2022-06-30 19:53:32 -04:00
real_glDeleteTextures()(n, textures);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glAlphaFunc, void, (GLenum func, GLclampf ref))
2024-10-20 01:19:08 -04:00
void media_glAlphaFunc(const GLenum func, const GLclampf ref) {
2022-06-30 19:53:32 -04:00
real_glAlphaFunc()(func, ref);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glGetFloatv, void, (GLenum pname, GLfloat *params))
2024-10-20 01:19:08 -04:00
void media_glGetFloatv(const GLenum pname, GLfloat *params) {
2022-06-30 19:53:32 -04:00
real_glGetFloatv()(pname, params);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glBindTexture, void, (GLenum target, GLuint texture))
2024-10-20 01:19:08 -04:00
void media_glBindTexture(const GLenum target, const GLuint texture) {
2022-06-30 19:53:32 -04:00
real_glBindTexture()(target, texture);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glTranslatef, void, (GLfloat x, GLfloat y, GLfloat z))
2024-10-20 01:19:08 -04:00
void media_glTranslatef(const GLfloat x, const GLfloat y, const GLfloat z) {
2022-06-30 19:53:32 -04:00
real_glTranslatef()(x, y, z);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glShadeModel, void, (GLenum mode))
2024-10-20 01:19:08 -04:00
void media_glShadeModel(const GLenum mode) {
2022-06-30 19:53:32 -04:00
real_glShadeModel()(mode);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glOrtho, void, (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far))
2024-10-20 01:19:08 -04:00
void media_glOrthof(const GLfloat left, const GLfloat right, const GLfloat bottom, const GLfloat top, const GLfloat near, const GLfloat far) {
2024-10-05 23:52:44 -04:00
real_glOrtho()(left, right, bottom, top, near, far);
2022-06-30 19:53:32 -04:00
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glDisable, void, (GLenum cap))
2024-10-20 01:19:08 -04:00
void media_glDisable(const GLenum cap) {
2022-06-30 19:53:32 -04:00
real_glDisable()(cap);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glCullFace, void, (GLenum mode))
2024-10-20 01:19:08 -04:00
void media_glCullFace(const GLenum mode) {
2022-06-30 19:53:32 -04:00
real_glCullFace()(mode);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glRotatef, void, (GLfloat angle, GLfloat x, GLfloat y, GLfloat z))
2024-10-20 01:19:08 -04:00
void media_glRotatef(const GLfloat angle, const GLfloat x, const GLfloat y, const GLfloat z) {
2022-06-30 19:53:32 -04:00
real_glRotatef()(angle, x, y, z);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glViewport, void, (GLint x, GLint y, GLsizei width, GLsizei height))
2024-10-20 01:19:08 -04:00
void media_glViewport(const GLint x, const GLint y, const GLsizei width, const GLsizei height) {
2022-06-30 19:53:32 -04:00
real_glViewport()(x, y, width, height);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glNormal3f, void, (GLfloat nx, GLfloat ny, GLfloat nz))
2024-10-20 01:19:08 -04:00
void media_glNormal3f(const GLfloat nx, const GLfloat ny, const GLfloat nz) {
2022-06-30 19:53:32 -04:00
real_glNormal3f()(nx, ny, nz);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glIsEnabled, GLboolean, (GLenum cap))
2024-10-20 01:19:08 -04:00
GLboolean media_glIsEnabled(const GLenum cap) {
2022-06-30 19:53:32 -04:00
return real_glIsEnabled()(cap);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glGetIntegerv, void, (GLenum pname, GLint *data))
2024-10-20 01:19:08 -04:00
void media_glGetIntegerv(const GLenum pname, GLint *data) {
2022-06-30 19:53:32 -04:00
real_glGetIntegerv()(pname, data);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glReadPixels, void, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *data))
2024-10-20 01:19:08 -04:00
void media_glReadPixels(const GLint x, const GLint y, const GLsizei width, const GLsizei height, const GLenum format, const GLenum type, void *data) {
2022-06-30 19:53:32 -04:00
real_glReadPixels()(x, y, width, height, format, type, data);
}
2024-10-09 10:43:37 -04:00
GL_FUNC(glGenBuffers, void, (GLsizei n, GLuint *buffers))
2024-10-20 01:19:08 -04:00
void media_glGenBuffers(const GLsizei n, GLuint *buffers) {
2022-09-20 18:25:27 -04:00
real_glGenBuffers()(n, buffers);
}
2024-10-18 01:41:59 -04:00
GL_FUNC(glNormalPointer, void, (GLenum type, GLsizei stride, const void *pointer))
2024-10-20 01:19:08 -04:00
void media_glNormalPointer(const GLenum type, const GLsizei stride, const void *pointer) {
2024-10-18 01:41:59 -04:00
real_glNormalPointer()(type, stride, pointer);
2024-10-18 15:14:18 -04:00
}
GL_FUNC(glLightfv, void, (GLenum light, GLenum pname, const GLfloat *params))
2024-10-20 01:19:08 -04:00
void media_glLightfv(const GLenum light, const GLenum pname, const GLfloat *params) {
2024-10-18 15:14:18 -04:00
real_glLightfv()(light, pname, params);
}
GL_FUNC(glColorMaterial, void, (GLenum face, GLenum mode))
2024-10-20 01:19:08 -04:00
void media_glColorMaterial(const GLenum face, const GLenum mode) {
2024-10-18 15:14:18 -04:00
real_glColorMaterial()(face, mode);
}
GL_FUNC(glLightModelfv, void, (GLenum pname, const GLfloat *params))
2024-10-20 01:19:08 -04:00
void media_glLightModelfv(const GLenum pname, const GLfloat *params) {
2024-10-18 15:14:18 -04:00
real_glLightModelfv()(pname, params);
}
// GL_EXT_multi_draw_arrays
GL_FUNC(glMultiDrawArraysEXT, void, (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount))
void media_glMultiDrawArrays(const GLenum mode, const GLint *first, const GLsizei *count, const GLsizei drawcount) {
real_glMultiDrawArraysEXT()(mode, first, count, drawcount);
2024-10-18 01:41:59 -04:00
}