[Bf-blender-cvs] [627566cb9a] blender2.8: OpenGL: use GL4 on Linux when available

Mike Erwin noreply at git.blender.org
Sun Feb 5 01:37:48 CET 2017


Commit: 627566cb9ac771c209508b3793f0c9456fb24798
Author: Mike Erwin
Date:   Sat Feb 4 19:35:54 2017 -0500
Branches: blender2.8
https://developer.blender.org/rB627566cb9ac771c209508b3793f0c9456fb24798

OpenGL: use GL4 on Linux when available

Minimum target is still 3.3

On AMD pro driver, asking for a 3.3 context gives us *exactly* 3.3, not 3.3+ as desired.

Have not tested proprietary NV or Intel drivers, but this fix should work on all vendors.

===================================================================

M	intern/ghost/intern/GHOST_WindowX11.cpp

===================================================================

diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp
index 992200a0b0..8cee785cdf 100644
--- a/intern/ghost/intern/GHOST_WindowX11.cpp
+++ b/intern/ghost/intern/GHOST_WindowX11.cpp
@@ -1316,10 +1316,12 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
 	if (type == GHOST_kDrawingContextTypeOpenGL) {
 
 		// During development:
+		//   try 4.x compatibility profile
 		//   try 3.3 compatibility profile
 		//   fall back to 3.0 if needed
 		//
 		// Final Blender 2.8:
+		//   try 4.x core profile
 		//   try 3.3 core profile
 		//   no fallbacks
 
@@ -1332,24 +1334,9 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
 #  error // must specify either core or compat at build time
 #endif
 
-		GHOST_Context *context = new GHOST_ContextGLX(
-		        m_wantStereoVisual,
-		        m_wantNumOfAASamples,
-		        m_window,
-		        m_display,
-		        m_visualInfo,
-		        (GLXFBConfig)m_fbconfig,
-		        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);
+		GHOST_Context *context;
 
-		if (context->initializeDrawingContext())
-			return context;
-		else {
-			delete context;
-
-			// since that failed try 3.0 (mostly for Mesa, which doesn't implement compatibility profile)
+		for (int minor = 5; minor >= 0; --minor) {
 			context = new GHOST_ContextGLX(
 			        m_wantStereoVisual,
 			        m_wantNumOfAASamples,
@@ -1357,8 +1344,8 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
 			        m_display,
 			        m_visualInfo,
 			        (GLXFBConfig)m_fbconfig,
-			        0, // no profile bit
-			        3, 0,
+			        profile_mask,
+			        4, minor,
 			        GHOST_OPENGL_GLX_CONTEXT_FLAGS | (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
 			        GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
 
@@ -1367,6 +1354,41 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
 			else
 				delete context;
 		}
+
+		context = new GHOST_ContextGLX(
+		        m_wantStereoVisual,
+		        m_wantNumOfAASamples,
+		        m_window,
+		        m_display,
+		        m_visualInfo,
+		        (GLXFBConfig)m_fbconfig,
+		        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);
+
+		if (context->initializeDrawingContext())
+			return context;
+		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;




More information about the Bf-blender-cvs mailing list