[Bf-blender-cvs] [9fd3435a93b] blender2.8: First batch of PRIM_QUAD_XXX replacement by PRIM_TRIANGLES.

Bastien Montagne noreply at git.blender.org
Mon Apr 10 15:22:10 CEST 2017


Commit: 9fd3435a93b45b80237419b1b218afdce72d4b9d
Author: Bastien Montagne
Date:   Mon Apr 10 15:16:59 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB9fd3435a93b45b80237419b1b218afdce72d4b9d

First batch of PRIM_QUAD_XXX replacement by PRIM_TRIANGLES.

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

M	source/blender/editors/interface/interface_draw.c
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/editors/space_time/space_time.c

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

diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index ab77d3caa17..5c3dd83e2a1 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -1922,29 +1922,62 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
 
 static void ui_shadowbox(unsigned pos, unsigned color, float minx, float miny, float maxx, float maxy, float shadsize, unsigned char alpha)
 {
+	/*          v1-_
+	 *          |   -_v2
+	 *          |     |
+	 *          |     |
+	 *          |     |
+	 * v7_______v3____v4
+	 * \        |     /
+	 *  \       |   _v5
+	 *  v8______v6_-
+	 */
+	const float v1[2] = {maxx,                   maxy - 0.3f * shadsize};
+	const float v2[2] = {maxx + shadsize,        maxy - 0.75f * shadsize};
+	const float v3[2] = {maxx,                   miny};
+	const float v4[2] = {maxx + shadsize,        miny};
+
+	const float v5[2] = {maxx + 0.7f * shadsize, miny - 0.7f * shadsize};
+
+	const float v6[2] = {maxx,                   miny - shadsize};
+	const float v7[2] = {minx + 0.3f * shadsize, miny};
+	const float v8[2] = {minx + 0.5f * shadsize, miny - shadsize};
+
 	/* right quad */
 	immAttrib4ub(color, 0, 0, 0, alpha);
-	immVertex2f(pos, maxx, miny);
-	immVertex2f(pos, maxx, maxy - 0.3f * shadsize);
+	immVertex2fv(pos, v3);
+	immVertex2fv(pos, v1);
 	immAttrib4ub(color, 0, 0, 0, 0);
-	immVertex2f(pos, maxx + shadsize, maxy - 0.75f * shadsize);
-	immVertex2f(pos, maxx + shadsize, miny);
-	
-	/* corner shape */
+	immVertex2fv(pos, v2);
+
+	immVertex2fv(pos, v2);
+	immVertex2fv(pos, v4);
 	immAttrib4ub(color, 0, 0, 0, alpha);
-	immVertex2f(pos, maxx, miny);
+	immVertex2fv(pos, v3);
+
+	/* corner shape */
+	/* immAttrib4ub(color, 0, 0, 0, alpha); */  /* Not needed, done above in previous tri */
+	immVertex2fv(pos, v3);
 	immAttrib4ub(color, 0, 0, 0, 0);
-	immVertex2f(pos, maxx + shadsize, miny);
-	immVertex2f(pos, maxx + 0.7f * shadsize, miny - 0.7f * shadsize);
-	immVertex2f(pos, maxx, miny - shadsize);
-	
-	/* bottom quad */
+	immVertex2fv(pos, v4);
+	immVertex2fv(pos, v5);
+
+	immVertex2fv(pos, v5);
+	immVertex2fv(pos, v6);
 	immAttrib4ub(color, 0, 0, 0, alpha);
-	immVertex2f(pos, minx + 0.3f * shadsize, miny);
-	immVertex2f(pos, maxx, miny);
+	immVertex2fv(pos, v3);
+
+	/* bottom quad */
+	/* immAttrib4ub(color, 0, 0, 0, alpha); */  /* Not needed, done above in previous tri */
+	immVertex2fv(pos, v3);
 	immAttrib4ub(color, 0, 0, 0, 0);
-	immVertex2f(pos, maxx, miny - shadsize);
-	immVertex2f(pos, minx + 0.5f * shadsize, miny - shadsize);
+	immVertex2fv(pos, v6);
+	immVertex2fv(pos, v8);
+
+	immVertex2fv(pos, v8);
+	immAttrib4ub(color, 0, 0, 0, alpha);
+	immVertex2fv(pos, v7);
+	immVertex2fv(pos, v3);
 }
 
 void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx, float maxy)
@@ -1957,8 +1990,7 @@ void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx,
 
 	immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
 
-#ifdef WITH_GL_PROFILE_COMPAT
-	immBegin(PRIM_QUADS_XXX, 36);
+	immBegin(PRIM_TRIANGLES, 54);
 
 	/* accumulated outline boxes to make shade not linear, is more pleasant */
 	ui_shadowbox(pos, color, minx, miny, maxx, maxy, 11.0, (20 * alpha) >> 8);
@@ -1966,7 +1998,6 @@ void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx,
 	ui_shadowbox(pos, color, minx, miny, maxx, maxy, 5.0, (80 * alpha) >> 8);
 	
 	immEnd();
-#endif
 
 	immUnbindProgram();
 
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index afe6d9ae121..bf620686c74 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -1799,18 +1799,19 @@ static void outliner_back(ARegion *ar)
 	int tot = (int)floor(ystart - ar->v2d.cur.ymin + 2 * UI_UNIT_Y) / (2 * UI_UNIT_Y);
 
 	if (tot > 0) {
-#ifdef WITH_GL_PROFILE_COMPAT
-		immBegin(PRIM_QUADS_XXX, 4 * tot);
+		immBegin(PRIM_TRIANGLES, 6 * tot);
 		while (tot--) {
 			y1 -= 2 * UI_UNIT_Y;
 			y2 = y1 + UI_UNIT_Y;
 			immVertex2f(pos, x1, y1);
 			immVertex2f(pos, x2, y1);
 			immVertex2f(pos, x2, y2);
+
+			immVertex2f(pos, x1, y1);
+			immVertex2f(pos, x2, y2);
 			immVertex2f(pos, x1, y2);
 		}
 		immEnd();
-#endif
 	}
 	immUnbindProgram();
 }
diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c
index a47fd3a2e34..9b149366670 100644
--- a/source/blender/editors/space_time/space_time.c
+++ b/source/blender/editors/space_time/space_time.c
@@ -196,8 +196,8 @@ static void time_draw_cache(SpaceTime *stime, Object *ob, Scene *scene)
 				break;
 		}
 
-		int sta = pid->cache->startframe, end = pid->cache->endframe;
-		int len = (end - sta + 1) * 4;
+		const int sta = pid->cache->startframe, end = pid->cache->endframe;
+		const int len = (end - sta + 1) * 6;
 
 		glEnable(GL_BLEND);
 
@@ -214,9 +214,8 @@ static void time_draw_cache(SpaceTime *stime, Object *ob, Scene *scene)
 
 		immUniformColor4fv(col);
 
-#ifdef WITH_GL_PROFILE_COMPAT
 		if (len > 0) {
-			immBeginAtMost(PRIM_QUADS_XXX, len);
+			immBeginAtMost(PRIM_TRIANGLES, len);
 
 			/* draw a quad for each cached frame */
 			for (int i = sta; i <= end; i++) {
@@ -224,13 +223,15 @@ static void time_draw_cache(SpaceTime *stime, Object *ob, Scene *scene)
 					immVertex2f(pos, (float)i - 0.5f, 0.0f);
 					immVertex2f(pos, (float)i - 0.5f, 1.0f);
 					immVertex2f(pos, (float)i + 0.5f, 1.0f);
+
+					immVertex2f(pos, (float)i - 0.5f, 0.0f);
+					immVertex2f(pos, (float)i + 0.5f, 1.0f);
 					immVertex2f(pos, (float)i + 0.5f, 0.0f);
 				}
 			}
 
 			immEnd();
 		}
-#endif
 
 		glDisable(GL_BLEND);




More information about the Bf-blender-cvs mailing list