forked from bartvdbraak/blender
Fix T46431: Init glew before glx-context crashes
Initialize glxew before glew, so we can check whats supported before creating the context. This also removes need for mxIgnoreNoVersion.
This commit is contained in:
parent
e0c05a1e6a
commit
9cea429f78
@ -40,9 +40,6 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
/* this should eventually be enabled, but causes T46431 */
|
|
||||||
// #define USE_CONTEXT_FLAGS
|
|
||||||
|
|
||||||
#ifdef WITH_GLEW_MX
|
#ifdef WITH_GLEW_MX
|
||||||
GLXEWContext *glxewContext = NULL;
|
GLXEWContext *glxewContext = NULL;
|
||||||
#endif
|
#endif
|
||||||
@ -156,19 +153,11 @@ GHOST_TSuccess GHOST_ContextGLX::initializeDrawingContext()
|
|||||||
XIOErrorHandler old_handler_io = XSetIOErrorHandler(GHOST_X11_ApplicationIOErrorHandler);
|
XIOErrorHandler old_handler_io = XSetIOErrorHandler(GHOST_X11_ApplicationIOErrorHandler);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_CONTEXT_FLAGS
|
/* important to initialize only glxew (_not_ glew),
|
||||||
/* needed so 'GLXEW_ARB_create_context' is valid */
|
* since this breaks w/ Mesa's `swrast`, see: T46431 */
|
||||||
mxIgnoreNoVersion(1);
|
glxewInit();
|
||||||
initContextGLXEW();
|
|
||||||
mxIgnoreNoVersion(0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_CONTEXT_FLAGS
|
if (GLXEW_ARB_create_context) {
|
||||||
if (GLXEW_ARB_create_context)
|
|
||||||
#else
|
|
||||||
if (0)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
int profileBitCore = m_contextProfileMask & GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
|
int profileBitCore = m_contextProfileMask & GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
|
||||||
int profileBitCompat = m_contextProfileMask & GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
|
int profileBitCompat = m_contextProfileMask & GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
|
||||||
|
|
||||||
@ -273,11 +262,9 @@ GHOST_TSuccess GHOST_ContextGLX::initializeDrawingContext()
|
|||||||
|
|
||||||
glXMakeCurrent(m_display, m_window, m_context);
|
glXMakeCurrent(m_display, m_window, m_context);
|
||||||
|
|
||||||
#ifndef USE_CONTEXT_FLAGS
|
|
||||||
// Seems that this has to be called after MakeCurrent,
|
// Seems that this has to be called after MakeCurrent,
|
||||||
// which means we cannot use glX extensions until after we create a context
|
// which means we cannot use glX extensions until after we create a context
|
||||||
initContextGLXEW();
|
initContextGLXEW();
|
||||||
#endif
|
|
||||||
|
|
||||||
initClearGL();
|
initClearGL();
|
||||||
::glXSwapBuffers(m_display, m_window);
|
::glXSwapBuffers(m_display, m_window);
|
||||||
|
@ -95,8 +95,6 @@ MXContext *mxGetCurrentContext (void);
|
|||||||
void mxMakeCurrentContext(MXContext *ctx);
|
void mxMakeCurrentContext(MXContext *ctx);
|
||||||
void mxDestroyContext (MXContext *ctx);
|
void mxDestroyContext (MXContext *ctx);
|
||||||
|
|
||||||
void mxIgnoreNoVersion(int ignore);
|
|
||||||
|
|
||||||
GLenum glew_chk(GLenum error, const char *file, int line, const char *text);
|
GLenum glew_chk(GLenum error, const char *file, int line, const char *text);
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
@ -34,8 +34,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static int ignore_version = 0;
|
|
||||||
|
|
||||||
#define CASE_CODE_RETURN_STR(code) case code: return #code;
|
#define CASE_CODE_RETURN_STR(code) case code: return #code;
|
||||||
|
|
||||||
static const char *get_glew_error_enum_string(GLenum error)
|
static const char *get_glew_error_enum_string(GLenum error)
|
||||||
@ -63,7 +61,7 @@ GLenum glew_chk(GLenum error, const char *file, int line, const char *text)
|
|||||||
const char *code = get_glew_error_enum_string(error);
|
const char *code = get_glew_error_enum_string(error);
|
||||||
const char *msg = (const char *)glewGetErrorString(error);
|
const char *msg = (const char *)glewGetErrorString(error);
|
||||||
|
|
||||||
if (error == GLEW_ERROR_NO_GL_VERSION && ignore_version)
|
if (error == GLEW_ERROR_NO_GL_VERSION)
|
||||||
return GLEW_OK;
|
return GLEW_OK;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
@ -144,8 +142,3 @@ void mxDestroyContext(MXContext *ctx)
|
|||||||
(void)ctx;
|
(void)ctx;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void mxIgnoreNoVersion(int ignore)
|
|
||||||
{
|
|
||||||
ignore_version = ignore;
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user