[Bf-blender-cvs] [0d5c5a8438b] blender2.8: OpenGL: early exit from functions that don't mix with core profile

Mike Erwin noreply at git.blender.org
Thu Apr 27 20:35:24 CEST 2017


Commit: 0d5c5a8438badf5e4921a96b9d4648d1d0dc3aee
Author: Mike Erwin
Date:   Thu Apr 27 14:00:38 2017 -0400
Branches: blender2.8
https://developer.blender.org/rB0d5c5a8438badf5e4921a96b9d4648d1d0dc3aee

OpenGL: early exit from functions that don't mix with core profile 

These parts will not be part of final viewport, but are called indirectly during the transition. To avoid runtime errors on core profile, exit early -- functions effectively do nothing.

I put the early exits inside the functions to avoid cluttering the code that calls these. But (long term) the calling functions need to change.

Basic shader's detect_options function was unused and full of old, so I deleted it.

Part of T51164

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

M	source/blender/editors/space_view3d/drawmesh.c
M	source/blender/gpu/intern/gpu_basic_shader.c

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

diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index 7db72d2c338..701efab0bd0 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -1171,6 +1171,11 @@ static bool tex_mat_set_face_editmesh_cb(void *userData, int index)
 void draw_mesh_textured(Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3D *rv3d,
                         Object *ob, DerivedMesh *dm, const int draw_flags)
 {
+#ifndef WITH_LEGACY_OPENGL
+	/* some legacy GL calls here will *crash* blender */
+	return;
+#endif
+
 	/* if not cycles, or preview-modifiers, or drawing matcaps */
 	if ((draw_flags & DRAW_MODIFIERS_PREVIEW) ||
 	    (v3d->flag2 & V3D_SHOW_SOLID_MATCAP) ||
diff --git a/source/blender/gpu/intern/gpu_basic_shader.c b/source/blender/gpu/intern/gpu_basic_shader.c
index ff385683a1e..42fb39a6eb0 100644
--- a/source/blender/gpu/intern/gpu_basic_shader.c
+++ b/source/blender/gpu/intern/gpu_basic_shader.c
@@ -190,31 +190,6 @@ static bool solid_compatible_lighting(void)
 	return ((directional & enabled) == enabled);
 }
 
-#if 0
-static int detect_options()
-{
-	GLint two_sided;
-	int options = 0;
-
-	if (glIsEnabled(GL_TEXTURE_2D))
-		options |= GPU_SHADER_TEXTURE_2D;
-	if (glIsEnabled(GL_TEXTURE_RECTANGLE))
-		options |= GPU_SHADER_TEXTURE_RECT;
-	GPU_SHADER_TEXTURE_RECT
-	if (glIsEnabled(GL_COLOR_MATERIAL))
-		options |= GPU_SHADER_USE_COLOR;
-
-	if (glIsEnabled(GL_LIGHTING))
-		options |= GPU_SHADER_LIGHTING;
-
-	glGetIntegerv(GL_LIGHT_MODEL_TWO_SIDE, &two_sided);
-	if (two_sided == GL_TRUE)
-		options |= GPU_SHADER_TWO_SIDED;
-	
-	return options;
-}
-#endif
-
 static GPUShader *gpu_basic_shader(int options)
 {
 	/* glsl code */
@@ -332,6 +307,10 @@ void GPU_basic_shader_colors(
         const float diffuse[3], const float specular[3],
         int shininess, float alpha)
 {
+#ifdef WITH_GL_PROFILE_CORE
+	return;
+#endif
+
 	float gl_diffuse[4], gl_specular[4];
 
 	if (diffuse)
@@ -353,6 +332,10 @@ void GPU_basic_shader_colors(
 
 void GPU_basic_shader_light_set(int light_num, GPULightData *light)
 {
+#ifdef WITH_GL_PROFILE_CORE
+	return;
+#endif
+
 	int light_bit = (1 << light_num);
 
 	/* note that light position is affected by the current modelview matrix! */
@@ -426,6 +409,10 @@ void GPU_basic_shader_light_set(int light_num, GPULightData *light)
 
 void GPU_basic_shader_light_set_viewer(bool local)
 {
+#ifdef WITH_GL_PROFILE_CORE
+	return;
+#endif
+
 	glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, (local) ? GL_TRUE: GL_FALSE);
 }




More information about the Bf-blender-cvs mailing list