diff --git a/CMakeLists.txt b/CMakeLists.txt index d2d213241..404e76be3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1326,6 +1326,11 @@ if(NOT USE_CONSOLE) ${OPENGL_LIBRARIES} ) include_directories(${GLEW_INCLUDE_DIR}) + # On some platforms, GLEW declares the userParam parameter of + # GLDEBUGPROCARB as const void *, and on other platforms, it's void *. + # Test which one works here. + set(CMAKE_REQUIRED_INCLUDES "${GLEW_INCLUDE_DIR}") + CHECK_CXX_SOURCE_COMPILES("#include \nvoid GLAPIENTRY OpenGLDebugProc(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char* message, const void* userParam) {}\nint main() { GLDEBUGPROCARB proc = &OpenGLDebugProc; }" GLDEBUGPROCARB_USERPARAM_IS_CONST) endif() if(USE_GTK) if(USE_GTK3) diff --git a/config.h.cmake b/config.h.cmake index d4df94551..00fc7e5d2 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -163,6 +163,10 @@ /* Define to 1 if you want to use Boost.Regex instead of . */ #cmakedefine USE_BOOST_REGEX 1 +/* Define to 1 if the userParam parameter to GLDEBUGPROCARB is const, as the + spec requires. */ +#cmakedefine GLDEBUGPROCARB_USERPARAM_IS_CONST 1 + /* Glib */ #cmakedefine WITH_GLIB 1 diff --git a/src/graphics/C4DrawGL.cpp b/src/graphics/C4DrawGL.cpp index 8f6b98d89..b717bc05d 100644 --- a/src/graphics/C4DrawGL.cpp +++ b/src/graphics/C4DrawGL.cpp @@ -77,7 +77,13 @@ namespace } } - void GLAPIENTRY OpenGLDebugProc(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char* message, const void* userParam) +#ifdef GLDEBUGPROCARB_USERPARAM_IS_CONST +#define USERPARAM_CONST const +#else +#define USERPARAM_CONST +#endif + + void GLAPIENTRY OpenGLDebugProc(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char* message, USERPARAM_CONST void* userParam) { const char *msg_source = MsgSourceToStr(source); const char *msg_type = MsgTypeToStr(type); @@ -91,6 +97,8 @@ namespace } } +#undef USERPARAM_CONST + CStdGL::CStdGL(): pMainCtx(0) {