[Bf-blender-cvs] [2a76da9] blender2.8: draw region emboss with new immediate mode

Mike Erwin noreply at git.blender.org
Sat Oct 8 05:46:55 CEST 2016


Commit: 2a76da9ec24c5c86cfcd2cbae8d3a71bd93a0e0c
Author: Mike Erwin
Date:   Fri Oct 7 23:44:54 2016 -0400
Branches: blender2.8
https://developer.blender.org/rB2a76da9ec24c5c86cfcd2cbae8d3a71bd93a0e0c

draw region emboss with new immediate mode

Simple convert of drawing emboss lines to new immediate mode.

Part of T49043

Reviewers: merwin

Reviewed By: merwin

Subscribers: dfelinto

Tags: #bf_blender_2.8

Differential Revision: https://developer.blender.org/D2271

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

M	source/blender/editors/screen/area.c

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

diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index a26d4f0..2acc9e7 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -91,21 +91,30 @@ static void region_draw_emboss(const ARegion *ar, const rcti *scirct)
 	glEnable(GL_BLEND);
 	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 	
+	VertexFormat* format = immVertexFormat();
+	unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
+	unsigned color = add_attrib(format, "color", GL_UNSIGNED_BYTE, 4, NORMALIZE_INT_TO_FLOAT);
+
+	immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
+	immBegin(GL_LINE_STRIP, 5);
+	
 	/* right  */
-	glColor4ub(0, 0, 0, 30);
-	sdrawline(rect.xmax, rect.ymin, rect.xmax, rect.ymax);
+	immAttrib4ub(color, 0, 0, 0, 30);
+	immVertex2f(pos, rect.xmax, rect.ymax);
+	immVertex2f(pos, rect.xmax, rect.ymin);
 	
 	/* bottom  */
-	glColor4ub(0, 0, 0, 30);
-	sdrawline(rect.xmin, rect.ymin, rect.xmax, rect.ymin);
+	immVertex2f(pos, rect.xmin, rect.ymin);
 	
-	/* top  */
-	glColor4ub(255, 255, 255, 30);
-	sdrawline(rect.xmin, rect.ymax, rect.xmax, rect.ymax);
-
 	/* left  */
-	glColor4ub(255, 255, 255, 30);
-	sdrawline(rect.xmin, rect.ymin, rect.xmin, rect.ymax);
+	immAttrib4ub(color, 255, 255, 255, 30);
+	immVertex2f(pos, rect.xmin, rect.ymax);
+
+	/* top  */
+	immVertex2f(pos, rect.xmax, rect.ymax);
+	
+	immEnd();
+	immUnbindProgram();
 	
 	glDisable(GL_BLEND);
 }




More information about the Bf-blender-cvs mailing list