[Bf-blender-cvs] [8cfcc44] master: OpenGL: new GPU_legacy_support() function

Mike Erwin noreply at git.blender.org
Mon Dec 7 00:59:11 CET 2015


Commit: 8cfcc444c63fc6346f70899d593c3adaf1f4c748
Author: Mike Erwin
Date:   Sun Dec 6 18:00:22 2015 -0500
Branches: master
https://developer.blender.org/rB8cfcc444c63fc6346f70899d593c3adaf1f4c748

OpenGL: new GPU_legacy_support() function

Is current context compatible with legacy GL (version 2.1)?

My earlier approach -- checking for GLEW_ARB_compatibility -- was not
enough.

This should always return true if we set our GL context up properly. It
will return false when we switch to core profile.

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

M	source/blender/gpu/GPU_extensions.h
M	source/blender/gpu/intern/gpu_extensions.c

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

diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h
index e07f902..a5bcedb 100644
--- a/source/blender/gpu/GPU_extensions.h
+++ b/source/blender/gpu/GPU_extensions.h
@@ -59,6 +59,7 @@ typedef struct GPUProgram GPUProgram;
 
 void GPU_extensions_disable(void);
 
+bool GPU_legacy_support(void);
 bool GPU_glsl_support(void);
 bool GPU_non_power_of_two_support(void);
 bool GPU_display_list_support(void);
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c
index 5e2fa19..4f3b84c 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -265,6 +265,27 @@ void gpu_extensions_exit(void)
 	GPU_invalid_tex_free();
 }
 
+bool GPU_legacy_support(void)
+{
+	// return whether or not current GL context is compatible with legacy OpenGL
+
+	if (GLEW_VERSION_3_2) {
+		static GLint profile = 0;
+
+		if (profile == 0) {
+			glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &profile);
+		}
+
+		return profile & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT;
+	}
+	else if (GLEW_VERSION_3_1) {
+		return GLEW_ARB_compatibility;
+	}
+	else {
+		return true;
+	}
+}
+
 bool GPU_glsl_support(void)
 {
 	/* always supported, still queried by game engine */
@@ -298,12 +319,12 @@ bool GPU_geometry_shader_support(void)
 	 * core profile clashes with our other shaders so accept compatibility only
 	 * other GL versions can use EXT_geometry_shader4 if available
 	 */
-	return (GLEW_VERSION_3_2 && GLEW_ARB_compatibility) || GLEW_EXT_geometry_shader4;
+	return (GLEW_VERSION_3_2 && GPU_legacy_support()) || GLEW_EXT_geometry_shader4;
 }
 
 static bool GPU_geometry_shader_support_via_extension(void)
 {
-	return GLEW_EXT_geometry_shader4 && !(GLEW_VERSION_3_2 && GLEW_ARB_compatibility);
+	return GLEW_EXT_geometry_shader4 && !(GLEW_VERSION_3_2 && GPU_legacy_support());
 }
 
 bool GPU_instanced_drawing_support(void)
@@ -1646,7 +1667,7 @@ static void shader_print_errors(const char *task, const char *log, const char **
 static const char *gpu_shader_version(void)
 {
 	if (GLEW_VERSION_3_2) {
-		if (GLEW_ARB_compatibility) {
+		if (GPU_legacy_support()) {
 			return "#version 150 compatibility\n";
 			/* highest version that is widely supported
 			 * gives us native geometry shaders!




More information about the Bf-blender-cvs mailing list