Skip to content

Commit 32880b2

Browse files
committed
hello_xr: Adapt debug callback, to fix OpenGL on MinGW
1 parent 2dc9060 commit 32880b2

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

Diff for: src/tests/hello_xr/graphicsplugin_opengl.cpp

+11-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
// SPDX-License-Identifier: Apache-2.0
44

55
#include "pch.h"
6+
7+
#ifdef __MINGW32__
8+
#define GL_ATTRIBUTE __attribute__((stdcall))
9+
#else
10+
#define GL_ATTRIBUTE
11+
#endif
612
#include "common.h"
713
#include "geometry.h"
814
#include "graphicsplugin.h"
@@ -149,17 +155,15 @@ struct OpenGLGraphicsPlugin : public IGraphicsPlugin {
149155

150156
#if !defined(XR_USE_PLATFORM_MACOS)
151157
glEnable(GL_DEBUG_OUTPUT);
152-
glDebugMessageCallback(
153-
[](GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message,
154-
const void* userParam) {
155-
((OpenGLGraphicsPlugin*)userParam)->DebugMessageCallback(source, type, id, severity, length, message);
156-
},
157-
this);
158+
glDebugMessageCallback((GLDEBUGPROC)&OpenGLGraphicsPlugin::DebugMessageCallbackTrampoline, this);
158159
#endif // !defined(XR_USE_PLATFORM_MACOS)
159160

160161
InitializeResources();
161162
}
162-
163+
static void GL_ATTRIBUTE DebugMessageCallbackTrampoline(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
164+
const GLchar* message, const void* userParam) {
165+
((OpenGLGraphicsPlugin*)userParam)->DebugMessageCallback(source, type, id, severity, length, message);
166+
}
163167
void InitializeResources() {
164168
glGenFramebuffers(1, &m_swapchainFramebuffer);
165169

0 commit comments

Comments
 (0)