Merge branch 'master' into blender2.8
[blender.git] / intern / ghost / intern / GHOST_WindowX11.cpp
index 47fbe12..992200a 100644 (file)
@@ -1314,33 +1314,24 @@ GHOST_WindowX11::
 GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type)
 {
        if (type == GHOST_kDrawingContextTypeOpenGL) {
-#if !defined(WITH_GL_EGL)
 
+               // During development:
+               //   try 3.3 compatibility profile
+               //   fall back to 3.0 if needed
+               //
+               // Final Blender 2.8:
+               //   try 3.3 core profile
+               //   no fallbacks
+
+               const int profile_mask =
 #if defined(WITH_GL_PROFILE_CORE)
-               GHOST_Context *context = new GHOST_ContextGLX(
-                       m_wantStereoVisual,
-                       m_wantNumOfAASamples,
-                       m_window,
-                       m_display,
-                       m_visualInfo,
-                       (GLXFBConfig)m_fbconfig,
-                       GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
-                       3, 2,
-                       GHOST_OPENGL_GLX_CONTEXT_FLAGS | (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
-                       GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
-#elif defined(WITH_GL_PROFILE_ES20)
-               GHOST_Context *context = new GHOST_ContextGLX(
-                       m_wantStereoVisual,
-                       m_wantNumOfAASamples,
-                       m_window,
-                       m_display,
-                       m_visualInfo,
-                       (GLXFBConfig)m_fbconfig,
-                       GLX_CONTEXT_ES2_PROFILE_BIT_EXT,
-                       2, 0,
-                       GHOST_OPENGL_GLX_CONTEXT_FLAGS | (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
-                       GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
+                       GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
 #elif defined(WITH_GL_PROFILE_COMPAT)
+                       GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
+#else
+#  error // must specify either core or compat at build time
+#endif
+
                GHOST_Context *context = new GHOST_ContextGLX(
                        m_wantStereoVisual,
                        m_wantNumOfAASamples,
@@ -1348,58 +1339,34 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
                        m_display,
                        m_visualInfo,
                        (GLXFBConfig)m_fbconfig,
-                       0, // profile bit
-                       0, 0,
+                       profile_mask,
+                       3, 3,
                        GHOST_OPENGL_GLX_CONTEXT_FLAGS | (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
                        GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
-#else
-#  error
-#endif
 
-#else
-
-#if defined(WITH_GL_PROFILE_CORE)
-               GHOST_Context *context = new GHOST_ContextEGL(
-                       m_wantStereoVisual,
-                       m_wantNumOfAASamples,
-                       m_window,
-                       m_display,
-                       EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
-                       3, 2,
-                       GHOST_OPENGL_EGL_CONTEXT_FLAGS,
-                       GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
-                       EGL_OPENGL_API);
-#elif defined(WITH_GL_PROFILE_ES20)
-               GHOST_Context *context = new GHOST_ContextEGL(
-                       m_wantStereoVisual,
-                       m_wantNumOfAASamples,
-                       m_window,
-                       m_display,
-                       0, // profile bit
-                       2, 0,
-                       GHOST_OPENGL_EGL_CONTEXT_FLAGS,
-                       GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
-                       EGL_OPENGL_ES_API);
-#elif defined(WITH_GL_PROFILE_COMPAT)
-               GHOST_Context *context = new GHOST_ContextEGL(
-                       m_wantStereoVisual,
-                       m_wantNumOfAASamples,
-                       m_window,
-                       m_display,
-                       0, // profile bit
-                       0, 0,
-                       GHOST_OPENGL_EGL_CONTEXT_FLAGS,
-                       GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
-                       EGL_OPENGL_API);
-#else
-#  error
-#endif
-
-#endif
                if (context->initializeDrawingContext())
                        return context;
-               else
+               else {
                        delete context;
+
+                       // since that failed try 3.0 (mostly for Mesa, which doesn't implement compatibility profile)
+                       context = new GHOST_ContextGLX(
+                               m_wantStereoVisual,
+                               m_wantNumOfAASamples,
+                               m_window,
+                               m_display,
+                               m_visualInfo,
+                               (GLXFBConfig)m_fbconfig,
+                               0, // no profile bit
+                               3, 0,
+                               GHOST_OPENGL_GLX_CONTEXT_FLAGS | (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
+                               GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
+
+                       if (context->initializeDrawingContext())
+                               return context;
+                       else
+                               delete context;
+               }
        }
 
        return NULL;