From d59bcdbd0706ac5eb90f55e346904315a9eaf3e2 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sun, 20 Feb 2022 23:18:17 +0100 Subject: [PATCH] Create OpenGL context using CreateContextAttribsARB --- source/Irrlicht/CGLXManager.cpp | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/source/Irrlicht/CGLXManager.cpp b/source/Irrlicht/CGLXManager.cpp index 4d5ef48a..a0c37ffb 100644 --- a/source/Irrlicht/CGLXManager.cpp +++ b/source/Irrlicht/CGLXManager.cpp @@ -319,12 +319,35 @@ bool CGLXManager::generateContext() { if (GlxWin) { - // create glx context - context = glXCreateNewContext((Display*)CurrentContext.OpenGLLinux.X11Display, (GLXFBConfig)glxFBConfig, GLX_RGBA_TYPE, NULL, True); - if (!context) +#if defined(GLX_ARB_create_context) + +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + PFNGLXCREATECONTEXTATTRIBSARBPROC glxCreateContextAttribsARB=(PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress(reinterpret_cast("glXCreateContextAttribsARB")); +#else + PFNGLXCREATECONTEXTATTRIBSARBPROC glxCreateContextAttribsARB=glXCreateContextAttribsARB; +#endif + + if (glxCreateContextAttribsARB) { - os::Printer::log("Could not create GLX rendering context.", ELL_WARNING); - return false; + int contextAttrBuffer[] = { + GLX_CONTEXT_MAJOR_VERSION_ARB, 3, + GLX_CONTEXT_MINOR_VERSION_ARB, 0, + // GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB, + None + }; + context = glxCreateContextAttribsARB((Display*)CurrentContext.OpenGLLinux.X11Display, (GLXFBConfig)glxFBConfig, NULL, True, contextAttrBuffer); + // transparently fall back to legacy call + } + if (!context) +#endif + { + // create glx context + context = glXCreateNewContext((Display*)CurrentContext.OpenGLLinux.X11Display, (GLXFBConfig)glxFBConfig, GLX_RGBA_TYPE, NULL, True); + if (!context) + { + os::Printer::log("Could not create GLX rendering context.", ELL_WARNING); + return false; + } } } else