From ecadb4faae9f49a16d7ecb46baa8bc36bacc874f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Mlynek?= Date: Tue, 7 Jan 2014 20:35:19 +0100 Subject: [PATCH 1/2] Use XGetErrorText() instead of our own table This fixes segfaults when the error code is not in the table --- libobs-opengl/gl-x11.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/libobs-opengl/gl-x11.c b/libobs-opengl/gl-x11.c index d1eebd6c0..046676acd 100644 --- a/libobs-opengl/gl-x11.c +++ b/libobs-opengl/gl-x11.c @@ -26,19 +26,7 @@ static const GLenum ctx_attribs[] = { None, }; -static const char* __GLX_error_table[] = { - "Success", - "Bad Screen", - "Bad Attribute", - "No Extension", - "Bad Visual", - "Bad Content", - "Bad Value", - "Bad Enumeration" -}; - -#define GET_GLX_ERROR(x) \ - __GLX_error_table[x] +#define ERROR_TEXT_LEN 1024 struct gl_windowinfo { uint32_t id; @@ -52,7 +40,11 @@ struct gl_platform { static int GLXErrorHandler(Display *disp, XErrorEvent *error) { - blog(LOG_ERROR, "GLX error: %s\n", GET_GLX_ERROR(error->error_code)); + char error_buf[ERROR_TEXT_LEN]; + + XGetErrorText(disp, error->error_code, error_buf, ERROR_TEXT_LEN); + blog(LOG_ERROR, "GLX error: %s\n", error_buf); + return 0; } From d3dab077cbd4267dadbfffce9ad1ae5d90bfff77 Mon Sep 17 00:00:00 2001 From: Zachary Lund Date: Tue, 7 Jan 2014 15:49:55 -0600 Subject: [PATCH 2/2] Another attempt to fix ARB_debug_output, hopefully the last one. --- libobs-opengl/gl-subsystem.c | 5 +++-- libobs-opengl/gl-windows.c | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libobs-opengl/gl-subsystem.c b/libobs-opengl/gl-subsystem.c index 05afb7f74..23a303ea4 100644 --- a/libobs-opengl/gl-subsystem.c +++ b/libobs-opengl/gl-subsystem.c @@ -72,9 +72,10 @@ static void GLEW_TEMP_API gl_debug_proc( static void gl_enable_debug() { /* Perhaps we should create GLEW contexts? */ - - if (GLEW_ARB_debug_output) + if (GLEW_VERSION_4_3) glDebugMessageCallback(gl_debug_proc, NULL); + if (GLEW_ARB_debug_output) + glDebugMessageCallbackARB(gl_debug_proc, NULL); else { blog(LOG_DEBUG, "Failed to set GL debug callback as it is " "not supported."); diff --git a/libobs-opengl/gl-windows.c b/libobs-opengl/gl-windows.c index cf04c62c1..0937b5765 100644 --- a/libobs-opengl/gl-windows.c +++ b/libobs-opengl/gl-windows.c @@ -237,6 +237,7 @@ static inline void required_extension_error(const char *extension) static bool gl_init_extensions(device_t device) { + glewExperimental = true; GLenum errorcode = glewInit(); if (errorcode != GLEW_OK) { blog(LOG_ERROR, "glewInit failed, %u", errorcode);