diff --git a/doomsday/engine/portable/include/gl_defer.h b/doomsday/engine/portable/include/gl_defer.h index 50b7ea90ad..90e85e0d4e 100644 --- a/doomsday/engine/portable/include/gl_defer.h +++ b/doomsday/engine/portable/include/gl_defer.h @@ -72,8 +72,11 @@ void GL_ReleaseReservedNames(void); */ void GL_DeferTextureUpload(const struct texturecontent_s* content); -void GL_Defer_e(void (GL_CALL *ptr)(GLenum), GLenum param); +// Deferring functions for various function signatures. +#define LIBDENG_GL_DEFER1(form, x) void GL_Defer_##form(void (GL_CALL *ptr)(x), x) +#define LIBDENG_GL_DEFER2(form, x, y) void GL_Defer_##form(void (GL_CALL* ptr)(x, y), x, y) -void GL_Defer_uintArray(void (GL_CALL *ptr)(GLsizei, const GLuint*), GLsizei s, const GLuint* v); +LIBDENG_GL_DEFER1(e, GLenum e); +LIBDENG_GL_DEFER2(uintArray, GLsizei count, const GLuint* values); #endif /* LIBDENG_GL_DEFERRED_H */ diff --git a/doomsday/engine/portable/include/gl_deferredapi.h b/doomsday/engine/portable/include/gl_deferredapi.h index d17d91034d..6bba4a9300 100644 --- a/doomsday/engine/portable/include/gl_deferredapi.h +++ b/doomsday/engine/portable/include/gl_deferredapi.h @@ -26,9 +26,14 @@ #ifndef LIBDENG_DEFERRED_GL_API_H #define LIBDENG_DEFERRED_GL_API_H +/** + * @def LIBDENG_DISABLE_DEFERRED_GL_API + * Disables the automatic rerouting of GL API calls to the deferring queue. + * Put this in the beginning of a source file, before all #includes. + */ #ifndef LIBDENG_DISABLE_DEFERRED_GL_API -#include "sys_opengl.h" +#include "sys_opengl.h" // ensure native OpenGL has been included #define glEnable(x) Deferred_glEnable(x) #define glDisable(x) Deferred_glDisable(x) diff --git a/doomsday/engine/portable/src/gl_defer.c b/doomsday/engine/portable/src/gl_defer.c index 3a0a479172..f93595aeb1 100644 --- a/doomsday/engine/portable/src/gl_defer.c +++ b/doomsday/engine/portable/src/gl_defer.c @@ -40,10 +40,10 @@ typedef enum { DTT_UPLOAD_TEXTURECONTENT = DEFERREDTASK_TYPES_FIRST, -DTT_FUNC_PTR_BEGIN, - DTT_FUNC_PTR_1E = DTT_FUNC_PTR_BEGIN, - DTT_FUNC_PTR_UINT_ARRAY, -DTT_FUNC_PTR_END, + DTT_FUNC_PTR_BEGIN, + DTT_FUNC_PTR_E = DTT_FUNC_PTR_BEGIN, + DTT_FUNC_PTR_UINT_ARRAY, + DTT_FUNC_PTR_END, DEFERREDTASK_TYPES_COUNT } deferredtask_type_t; @@ -58,7 +58,7 @@ typedef struct deferredtask_s { typedef struct apifunc_s { union { - void (GL_CALL *ptr_1e)(GLenum); + void (GL_CALL *ptr_e)(GLenum); void (GL_CALL *ptr_uintArray)(GLsizei, const GLuint*); } func; union { @@ -151,20 +151,20 @@ static void destroyTask(deferredtask_t* d) free(d); } -void GL_Defer1e(void (GL_CALL *ptr)(GLenum), GLenum param) +LIBDENG_GL_DEFER1(e, GLenum e) { apifunc_t* api = malloc(sizeof(apifunc_t)); - api->func.ptr_1e = ptr; - api->param.e = param; + api->func.ptr_e = ptr; + api->param.e = e; #ifdef _DEBUG - fprintf(stderr, "GL_Defer1e: ptr=%p param=%i\n", ptr, param); + fprintf(stderr, "GL_Defer1e: ptr=%p enum=%i\n", ptr, e); #endif - enqueueTask(DTT_FUNC_PTR_1E, api); + enqueueTask(DTT_FUNC_PTR_E, api); } -void GL_Defer_uintArray(void (GL_CALL *ptr)(GLsizei, const GLuint*), GLsizei s, const GLuint* v) +LIBDENG_GL_DEFER2(uintArray, GLsizei s, const GLuint* v) { apifunc_t* api = malloc(sizeof(apifunc_t)); api->func.ptr_uintArray = ptr; @@ -323,11 +323,11 @@ static void processTask(deferredtask_t* task) GL_UploadTextureContent(task->data); break; - case DTT_FUNC_PTR_1E: + case DTT_FUNC_PTR_E: #ifdef _DEBUG - fprintf(stderr, "processDeferred: ptr=%p param=%i\n", api->func.ptr_1e, api->param.e); + fprintf(stderr, "processDeferred: ptr=%p param=%i\n", api->func.ptr_e, api->param.e); #endif - api->func.ptr_1e(api->param.e); + api->func.ptr_e(api->param.e); break; case DTT_FUNC_PTR_UINT_ARRAY: