[Bf-blender-cvs] [2653758] blender2.8: blender 2.8: OpenGL immediate mode: anim_draw

Mike Erwin noreply at git.blender.org
Tue Nov 15 18:19:51 CET 2016


Commit: 2653758adcb241dfc7934f1af45f2f0700478a80
Author: Mike Erwin
Date:   Tue Nov 15 12:16:47 2016 -0500
Branches: blender2.8
https://developer.blender.org/rB2653758adcb241dfc7934f1af45f2f0700478a80

blender 2.8: OpenGL immediate mode: anim_draw

Reviewers: merwin

Reviewed By: merwin

Maniphest Tasks: T49043

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

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

M	source/blender/editors/animation/anim_draw.c

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

diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index 33e44d7..58b9b8e 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -62,6 +62,8 @@
 #include "UI_resources.h"
 #include "UI_view2d.h"
 
+#include "GPU_immediate.h"
+
 /* *************************************************** */
 /* CURRENT FRAME DRAWING */
 
@@ -95,9 +97,16 @@ static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const
 	x = cfra * xscale;
 	y = 0.9f * U.widget_unit;
 	
+	VertexFormat *format = immVertexFormat();
+	unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
+
+	immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+
 	/* draw green box around/behind text */
-	UI_ThemeColorShade(TH_CFRAME, 0);
-	glRectf(x, y,  x + slen,  y + 0.75f * U.widget_unit);
+	immUniformThemeColorShade(TH_CFRAME, 0);
+
+	immRectf(pos, x, y,  x + slen,  y + 0.75f * U.widget_unit);
+	immUnbindProgram();
 	
 	/* draw current frame number - black text */
 	UI_ThemeColor(TH_TEXT);
@@ -112,17 +121,23 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag)
 {
 	Scene *scene = CTX_data_scene(C);
 
-	/* Draw a light green line to indicate current frame */
-	UI_ThemeColor(TH_CFRAME);
-
 	const float x = (float)(scene->r.cfra * scene->r.framelen);
 
 	glLineWidth((flag & DRAWCFRA_WIDE) ? 3.0 : 2.0);
 
-	glBegin(GL_LINES);
-	glVertex2f(x, v2d->cur.ymin - 500.0f); /* XXX arbitrary... want it go to bottom */
-	glVertex2f(x, v2d->cur.ymax);
-	glEnd();
+	VertexFormat *format = immVertexFormat();
+	unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
+
+	immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+
+	/* Draw a light green line to indicate current frame */
+	immUniformThemeColor(TH_CFRAME);
+
+	immBegin(GL_LINES, 2);
+	immVertex2f(pos, x, v2d->cur.ymin - 500.0f); /* XXX arbitrary... want it go to bottom */
+	immVertex2f(pos, x, v2d->cur.ymax);
+	immEnd();
+	immUnbindProgram();
 
 	/* Draw current frame number in a little box */
 	if (flag & DRAWCFRA_SHOW_NUMBOX) {
@@ -144,17 +159,24 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width)
 	if (PRVRANGEON) {
 		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 		glEnable(GL_BLEND);
-		glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
-		
+
+		VertexFormat *format = immVertexFormat();
+		unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
+
+		immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+		immUniformColor4f(0.0f, 0.0f, 0.0f, 0.4f);
+
 		/* only draw two separate 'curtains' if there's no overlap between them */
 		if (PSFRA < PEFRA + end_frame_width) {
-			glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
-			glRectf((float)(PEFRA + end_frame_width), v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
+			immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
+			immRectf(pos, (float)(PEFRA + end_frame_width), v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
 		}
 		else {
-			glRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
+			immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
 		}
-		
+
+		immUnbindProgram();
+
 		glDisable(GL_BLEND);
 	}
 }




More information about the Bf-blender-cvs mailing list