From 0808cb15e3d8c2ee16cd063d19a6fed5cfe153c2 Mon Sep 17 00:00:00 2001 From: Rylie Pavlik Date: Wed, 13 May 2020 16:11:04 -0500 Subject: [PATCH] hello_xr: Adapt debug callback, to fix OpenGL on MinGW --- src/tests/hello_xr/graphicsplugin_opengl.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/tests/hello_xr/graphicsplugin_opengl.cpp b/src/tests/hello_xr/graphicsplugin_opengl.cpp index 43e21a3ce..3661e9616 100644 --- a/src/tests/hello_xr/graphicsplugin_opengl.cpp +++ b/src/tests/hello_xr/graphicsplugin_opengl.cpp @@ -3,6 +3,12 @@ // SPDX-License-Identifier: Apache-2.0 #include "pch.h" + +#ifdef __MINGW32__ +#define GL_ATTRIBUTE __attribute__((stdcall)) +#else +#define GL_ATTRIBUTE +#endif #include "common.h" #include "geometry.h" #include "graphicsplugin.h" @@ -149,17 +155,15 @@ struct OpenGLGraphicsPlugin : public IGraphicsPlugin { #if !defined(XR_USE_PLATFORM_MACOS) glEnable(GL_DEBUG_OUTPUT); - glDebugMessageCallback( - [](GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, - const void* userParam) { - ((OpenGLGraphicsPlugin*)userParam)->DebugMessageCallback(source, type, id, severity, length, message); - }, - this); + glDebugMessageCallback((GLDEBUGPROC)&OpenGLGraphicsPlugin::DebugMessageCallbackTrampoline, this); #endif // !defined(XR_USE_PLATFORM_MACOS) InitializeResources(); } - + static void GL_ATTRIBUTE DebugMessageCallbackTrampoline(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, + const GLchar* message, const void* userParam) { + ((OpenGLGraphicsPlugin*)userParam)->DebugMessageCallback(source, type, id, severity, length, message); + } void InitializeResources() { glGenFramebuffers(1, &m_swapchainFramebuffer);