diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-11-22 20:51:56 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-11-22 20:51:56 -0300 |
commit | 9d635f06298f84a59160e8e8cce0187cde6cf74e (patch) | |
tree | 6d3890389f49c3345d0ff6541b406ec968cd2667 /platform/x11/context_gl_x11.cpp | |
parent | 943d27f46ded993105928c4a46414aa16d84115e (diff) | |
download | redot-engine-9d635f06298f84a59160e8e8cce0187cde6cf74e.tar.gz |
Migrated from GLES to GLAD, fixes many issues.
Diffstat (limited to 'platform/x11/context_gl_x11.cpp')
-rw-r--r-- | platform/x11/context_gl_x11.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/platform/x11/context_gl_x11.cpp b/platform/x11/context_gl_x11.cpp index ccf7a801ef..789f346608 100644 --- a/platform/x11/context_gl_x11.cpp +++ b/platform/x11/context_gl_x11.cpp @@ -76,6 +76,13 @@ static GLWrapperFuncPtr wrapper_get_proc_address(const char* p_function) { }*/ +static bool ctxErrorOccurred = false; +static int ctxErrorHandler( Display *dpy, XErrorEvent *ev ) +{ + ctxErrorOccurred = true; + return 0; +} + Error ContextGL_X11::initialize() { @@ -133,21 +140,31 @@ Error ContextGL_X11::initialize() { //}; + int (*oldHandler)(Display*, XErrorEvent*) = + XSetErrorHandler(&ctxErrorHandler); + + if (!opengl_3_context) { //oldstyle context: p->glx_context = glXCreateContext(x11_display, vi, 0, GL_TRUE); } else { static int context_attribs[] = { GLX_CONTEXT_MAJOR_VERSION_ARB, 3, - GLX_CONTEXT_MINOR_VERSION_ARB, 0, - GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB, + GLX_CONTEXT_MINOR_VERSION_ARB, 3, + GLX_CONTEXT_FLAGS_ARB , GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB|GLX_CONTEXT_DEBUG_BIT_ARB, None }; p->glx_context = glXCreateContextAttribsARB(x11_display, fbc[0], NULL, true, context_attribs); - ERR_FAIL_COND_V(!p->glx_context,ERR_UNCONFIGURED); + ERR_EXPLAIN("Could not obtain an OpenGL 3.3 context!"); + ERR_FAIL_COND_V(ctxErrorOccurred || !p->glx_context,ERR_UNCONFIGURED); } + XSync( x11_display, False ); + XSetErrorHandler( oldHandler ); + + print_line("ALL IS GOOD"); + glXMakeCurrent(x11_display, x11_window, p->glx_context); /* |