Commit e07230ed authored by Sebastian Lackner's avatar Sebastian Lackner Committed by Alexandre Julliard

opengl32: Add wrappers for glDebugMessageCallback to handle calling convention differences.

parent d900547f
......@@ -416,6 +416,9 @@ sub needs_wrapper($$)
my %funcs =
(
"glDebugEntry" => 1,
"glDebugMessageCallback" => 1,
"glDebugMessageCallbackAMD" => 1,
"glDebugMessageCallbackARB" => 1,
"glGetIntegerv" => 1,
"glGetString" => 1,
"glGetStringi" => 1,
......
......@@ -2327,27 +2327,6 @@ static void WINAPI glCurrentPaletteMatrixARB( GLint index )
funcs->ext.p_glCurrentPaletteMatrixARB( index );
}
static void WINAPI glDebugMessageCallback( GLDEBUGPROC callback, const void *userParam )
{
const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
TRACE( "(%p, %p)\n", callback, userParam );
funcs->ext.p_glDebugMessageCallback( callback, userParam );
}
static void WINAPI glDebugMessageCallbackAMD( GLDEBUGPROCAMD callback, void *userParam )
{
const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
TRACE( "(%p, %p)\n", callback, userParam );
funcs->ext.p_glDebugMessageCallbackAMD( callback, userParam );
}
static void WINAPI glDebugMessageCallbackARB( GLDEBUGPROCARB callback, const void *userParam )
{
const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
TRACE( "(%p, %p)\n", callback, userParam );
funcs->ext.p_glDebugMessageCallbackARB( callback, userParam );
}
static void WINAPI glDebugMessageControl( GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled )
{
const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
......@@ -18686,6 +18665,9 @@ static BOOL WINAPI wglSwapIntervalEXT( int interval )
return funcs->ext.p_wglSwapIntervalEXT( interval );
}
extern void WINAPI glDebugMessageCallback( GLDEBUGPROC callback, const void *userParam ) DECLSPEC_HIDDEN;
extern void WINAPI glDebugMessageCallbackAMD( GLDEBUGPROCAMD callback, void *userParam ) DECLSPEC_HIDDEN;
extern void WINAPI glDebugMessageCallbackARB( GLDEBUGPROCARB callback, const void *userParam ) DECLSPEC_HIDDEN;
extern const GLubyte * WINAPI glGetStringi( GLenum name, GLuint index ) DECLSPEC_HIDDEN;
extern BOOL WINAPI wglBindTexImageARB( HPBUFFERARB hPbuffer, int iBuffer ) DECLSPEC_HIDDEN;
extern HGLRC WINAPI wglCreateContextAttribsARB( HDC hDC, HGLRC hShareContext, const int *attribList ) DECLSPEC_HIDDEN;
......
......@@ -48,6 +48,11 @@ static HDC (WINAPI *pwglGetPbufferDCARB)(HPBUFFERARB);
static BOOL (WINAPI *pwglSwapIntervalEXT)(int interval);
static int (WINAPI *pwglGetSwapIntervalEXT)(void);
/* GL_ARB_debug_output */
static void (WINAPI *pglDebugMessageCallbackARB)(void *, void *);
static void (WINAPI *pglDebugMessageControlARB)(GLenum, GLenum, GLenum, GLsizei, const GLuint *, GLboolean);
static void (WINAPI *pglDebugMessageInsertARB)(GLenum, GLenum, GLuint, GLenum, GLsizei, const char *);
static const char* wgl_extensions = NULL;
static void init_functions(void)
......@@ -80,6 +85,11 @@ static void init_functions(void)
GET_PROC(wglSwapIntervalEXT)
GET_PROC(wglGetSwapIntervalEXT)
/* GL_ARB_debug_output */
GET_PROC(glDebugMessageCallbackARB)
GET_PROC(glDebugMessageControlARB)
GET_PROC(glDebugMessageInsertARB)
#undef GET_PROC
}
......@@ -305,6 +315,39 @@ static void test_choosepixelformat(void)
pfd.cAuxBuffers = 0;
}
static void WINAPI gl_debug_message_callback(GLenum source, GLenum type, GLuint id, GLenum severity,
GLsizei length, const GLchar *message, const void *userParam)
{
DWORD *count = (DWORD *)userParam;
(*count)++;
}
static void test_debug_message_callback(void)
{
static const char testmsg[] = "Hello World";
DWORD count;
if (!pglDebugMessageCallbackARB)
{
skip("glDebugMessageCallbackARB not supported\n");
return;
}
glEnable(GL_DEBUG_OUTPUT);
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
pglDebugMessageCallbackARB(gl_debug_message_callback, &count);
pglDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
count = 0;
pglDebugMessageInsertARB(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_OTHER, 0x42424242,
GL_DEBUG_SEVERITY_LOW, sizeof(testmsg), testmsg);
ok(count == 1, "expected count == 1, got %u\n", count);
glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
glDisable(GL_DEBUG_OUTPUT);
}
static void test_setpixelformat(HDC winhdc)
{
int res = 0;
......@@ -1786,6 +1829,7 @@ START_TEST(opengl)
}
test_choosepixelformat();
test_debug_message_callback();
test_setpixelformat(hdc);
test_destroy(hdc);
test_sharelists(hdc);
......
......@@ -58,6 +58,9 @@ struct opengl_context
DWORD tid; /* thread that the context is current in */
HDC draw_dc; /* current drawing DC */
HDC read_dc; /* current reading DC */
void (CALLBACK *debug_callback)(GLenum, GLenum, GLuint, GLenum,
GLsizei, const GLchar *, const void *); /* debug callback */
const void *debug_user; /* debug user parameter */
GLubyte *extensions; /* extension string */
GLuint *disabled_exts; /* indices of disabled extensions */
struct wgl_context *drv_ctx; /* driver context */
......@@ -1746,6 +1749,60 @@ const GLubyte * WINAPI glGetString( GLenum name )
return ret;
}
/* wrapper for glDebugMessageCallback* functions */
static void gl_debug_message_callback( GLenum source, GLenum type, GLuint id, GLenum severity,
GLsizei length, const GLchar *message,const void *userParam )
{
struct wgl_handle *ptr = (struct wgl_handle *)userParam;
if (!ptr->u.context->debug_callback) return;
ptr->u.context->debug_callback( source, type, id, severity, length, message, ptr->u.context->debug_user );
}
/***********************************************************************
* glDebugMessageCallback
*/
void WINAPI glDebugMessageCallback( GLDEBUGPROC callback, const void *userParam )
{
struct wgl_handle *ptr = get_current_context_ptr();
const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
TRACE( "(%p, %p)\n", callback, userParam );
ptr->u.context->debug_callback = callback;
ptr->u.context->debug_user = userParam;
funcs->ext.p_glDebugMessageCallback( gl_debug_message_callback, ptr );
}
/***********************************************************************
* glDebugMessageCallbackAMD
*/
void WINAPI glDebugMessageCallbackAMD( GLDEBUGPROCAMD callback, void *userParam )
{
struct wgl_handle *ptr = get_current_context_ptr();
const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
TRACE( "(%p, %p)\n", callback, userParam );
ptr->u.context->debug_callback = callback;
ptr->u.context->debug_user = userParam;
funcs->ext.p_glDebugMessageCallbackAMD( gl_debug_message_callback, ptr );
}
/***********************************************************************
* glDebugMessageCallbackARB
*/
void WINAPI glDebugMessageCallbackARB( GLDEBUGPROCARB callback, const void *userParam )
{
struct wgl_handle *ptr = get_current_context_ptr();
const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
TRACE( "(%p, %p)\n", callback, userParam );
ptr->u.context->debug_callback = callback;
ptr->u.context->debug_user = userParam;
funcs->ext.p_glDebugMessageCallbackARB( gl_debug_message_callback, ptr );
}
/***********************************************************************
* OpenGL initialisation routine
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment