[Bf-blender-cvs] [0d4db6e] temp_viewport_fx_merge: Matrix API: explicitly set the matrix we tweak - much clearer this way and we may even use explicit stacks in the future.

Antony Riakiotakis noreply at git.blender.org
Fri Apr 3 18:06:37 CEST 2015


Commit: 0d4db6e9e8c05324b9ae422118903c3a7a1ee870
Author: Antony Riakiotakis
Date:   Fri Apr 3 16:17:39 2015 +0200
Branches: temp_viewport_fx_merge
https://developer.blender.org/rB0d4db6e9e8c05324b9ae422118903c3a7a1ee870

Matrix API: explicitly set the matrix we tweak - much clearer this way and
we may even use explicit stacks in the future.

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

M	source/blender/blenfont/intern/blf.c
M	source/blender/editors/animation/anim_draw.c
M	source/blender/editors/animation/anim_markers.c
M	source/blender/editors/animation/keyframes_draw.c
M	source/blender/editors/armature/editarmature_sketch.c
M	source/blender/editors/gpencil/drawgpencil.c
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_draw.c
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/editors/interface/view2d.c
M	source/blender/editors/mask/mask_draw.c
M	source/blender/editors/mesh/editmesh_knife.c
M	source/blender/editors/mesh/editmesh_loopcut.c
M	source/blender/editors/physics/particle_edit.c
M	source/blender/editors/render/render_opengl.c
M	source/blender/editors/screen/area.c
M	source/blender/editors/screen/glutil.c
M	source/blender/editors/screen/screendump.c
M	source/blender/editors/sculpt_paint/paint_cursor.c
M	source/blender/editors/sculpt_paint/sculpt_uv.c
M	source/blender/editors/space_clip/clip_dopesheet_draw.c
M	source/blender/editors/space_clip/clip_draw.c
M	source/blender/editors/space_clip/clip_graph_draw.c
M	source/blender/editors/space_clip/clip_utils.c
M	source/blender/editors/space_clip/space_clip.c
M	source/blender/editors/space_graph/graph_draw.c
M	source/blender/editors/space_image/image_draw.c
M	source/blender/editors/space_node/drawnode.c
M	source/blender/editors/space_sequencer/sequencer_draw.c
M	source/blender/editors/space_time/space_time.c
M	source/blender/editors/space_view3d/drawanimviz.c
M	source/blender/editors/space_view3d/drawarmature.c
M	source/blender/editors/space_view3d/drawmesh.c
M	source/blender/editors/space_view3d/drawobject.c
M	source/blender/editors/space_view3d/drawsimdebug.c
M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/editors/space_view3d/view3d_select.c
M	source/blender/editors/space_view3d/view3d_view.c
M	source/blender/editors/transform/transform.c
M	source/blender/editors/transform/transform_constraints.c
M	source/blender/editors/transform/transform_generics.c
M	source/blender/editors/transform/transform_manipulator.c
M	source/blender/editors/uvedit/uvedit_draw.c
M	source/blender/gpu/GPU_matrix.h
M	source/blender/gpu/intern/gpu_draw.c
M	source/blender/gpu/intern/gpu_extensions.c
M	source/blender/gpu/intern/gpu_matrix.c
M	source/blender/windowmanager/intern/wm_gesture.c
M	source/blender/windowmanager/intern/wm_operators.c
M	source/blender/windowmanager/intern/wm_playanim.c
M	source/blender/windowmanager/intern/wm_subwindow.c
M	source/gameengine/Ketsji/BL_Texture.cpp
M	source/gameengine/Ketsji/KX_BlenderMaterial.cpp
M	source/gameengine/Ketsji/KX_Dome.cpp
M	source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
M	source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp

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

diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index eec3981..1c003bb 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -493,7 +493,7 @@ void BLF_rotation_default(float angle)
 	}
 }
 
-static void blf_draw__start(FontBLF *font, GLint *mode, GLint *param)
+static void blf_draw__start(FontBLF *font, GLint *param)
 {
 	/*
 	 * The pixmap alignment hack is handle
@@ -504,26 +504,21 @@ static void blf_draw__start(FontBLF *font, GLint *mode, GLint *param)
 	glEnable(GL_TEXTURE_2D);
 	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
-	/* Save the current matrix mode. */
-	glGetIntegerv(GL_MATRIX_MODE, mode);
+	gpuPushMatrix(GPU_TEXTURE);
+	gpuLoadIdentity(GPU_TEXTURE);
 
-	gpuMatrixMode(GL_TEXTURE);
-	gpuPushMatrix();
-	gpuLoadIdentity();
-
-	gpuMatrixMode(GL_MODELVIEW);
-	gpuPushMatrix();
+	gpuPushMatrix(GPU_MODELVIEW);
 
 	if (font->flags & BLF_MATRIX)
-		gpuMultMatrixd((GLdouble *)&font->m);
+		gpuMultMatrixd(GPU_MODELVIEW, font->m);
 
-	gpuTranslate(font->pos[0], font->pos[1], font->pos[2]);
+	gpuTranslate(GPU_MODELVIEW, font->pos[0], font->pos[1], font->pos[2]);
 
 	if (font->flags & BLF_ASPECT)
-		gpuScale(font->aspect[0], font->aspect[1], font->aspect[2]);
+		gpuScale(GPU_MODELVIEW, font->aspect[0], font->aspect[1], font->aspect[2]);
 
 	if (font->flags & BLF_ROTATION)  /* radians -> degrees */
-		gpuRotateAxis(font->angle * (float)(180.0 / M_PI), 'Z');
+		gpuRotateAxis(GPU_MODELVIEW, font->angle * (float)(180.0 / M_PI), 'Z');
 
 	if (font->shadow || font->blur)
 		glGetFloatv(GL_CURRENT_COLOR, font->orig_col);
@@ -537,20 +532,14 @@ static void blf_draw__start(FontBLF *font, GLint *mode, GLint *param)
 		glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
 }
 
-static void blf_draw__end(GLint mode, GLint param)
+static void blf_draw__end(GLint param)
 {
 	/* and restore the original value. */
 	if (param != GL_MODULATE)
 		glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, param);
 
-	gpuMatrixMode(GL_TEXTURE);
-	gpuPopMatrix();
-
-	gpuMatrixMode(GL_MODELVIEW);
-	gpuPopMatrix();
-
-	if (mode != GL_MODELVIEW)
-		gpuMatrixMode(mode);
+	gpuPopMatrix(GPU_TEXTURE);
+	gpuPopMatrix(GPU_MODELVIEW);
 
 	glDisable(GL_BLEND);
 	glDisable(GL_TEXTURE_2D);
@@ -559,37 +548,37 @@ static void blf_draw__end(GLint mode, GLint param)
 void BLF_draw(int fontid, const char *str, size_t len)
 {
 	FontBLF *font = blf_get(fontid);
-	GLint mode, param;
+	GLint param;
 
 	if (font && font->glyph_cache) {
-		blf_draw__start(font, &mode, &param);
+		blf_draw__start(font, &param);
 		blf_font_draw(font, str, len);
-		blf_draw__end(mode, param);
+		blf_draw__end(param);
 	}
 }
 
 void BLF_draw_ascii(int fontid, const char *str, size_t len)
 {
 	FontBLF *font = blf_get(fontid);
-	GLint mode, param;
+	GLint param;
 
 	if (font && font->glyph_cache) {
-		blf_draw__start(font, &mode, &param);
+		blf_draw__start(font, &param);
 		blf_font_draw_ascii(font, str, len);
-		blf_draw__end(mode, param);
+		blf_draw__end(param);
 	}
 }
 
 int BLF_draw_mono(int fontid, const char *str, size_t len, int cwidth)
 {
 	FontBLF *font = blf_get(fontid);
-	GLint mode, param;
+	GLint param;
 	int columns = 0;
 
 	if (font && font->glyph_cache) {
-		blf_draw__start(font, &mode, &param);
+		blf_draw__start(font, &param);
 		columns = blf_font_draw_mono(font, str, len, cwidth);
-		blf_draw__end(mode, param);
+		blf_draw__end(param);
 	}
 
 	return columns;
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index 7fcf74f..ac184f6 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -68,7 +68,7 @@ static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const
 	
 	/* because the frame number text is subject to the same scaling as the contents of the view */
 	UI_view2d_scale_get(v2d, &xscale, &yscale);
-	gpuScale(1.0f / xscale, 1.0f, 1.0f);
+	gpuScale(GPU_MODELVIEW, 1.0f / xscale, 1.0f, 1.0f);
 	
 	/* get timecode string 
 	 *	- padding on str-buf passed so that it doesn't sit on the frame indicator
@@ -97,7 +97,7 @@ static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const
 	UI_fontstyle_draw_simple(fstyle, x - 0.25f * U.widget_unit, y + 0.15f * U.widget_unit, numstr);
 	
 	/* restore view transform */
-	gpuScale(xscale, 1.0, 1.0);
+	gpuScale(GPU_MODELVIEW, xscale, 1.0, 1.0);
 }
 
 /* General call for drawing current frame indicator in animation editor */
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 163617b..c35ff46 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -442,7 +442,7 @@ void ED_markers_draw(const bContext *C, int flag)
 	/* no time correction for framelen! space is drawn with old values */
 	ypixels = BLI_rcti_size_y(&v2d->mask);
 	UI_view2d_scale_get(v2d, &xscale, &yscale);
-	gpuScale(1.0f / xscale, 1.0f, 1.0f);
+	gpuScale(GPU_MODELVIEW, 1.0f / xscale, 1.0f, 1.0f);
 
 	/* x-bounds with offset for text (adjust for long string, avoid checking string width) */
 	font_width_max = (10 * UI_DPI_FAC) / xscale;
@@ -465,7 +465,7 @@ void ED_markers_draw(const bContext *C, int flag)
 		}
 	}
 
-	gpuScale(xscale, 1.0f, 1.0f);
+	gpuScale(GPU_MODELVIEW, xscale, 1.0f, 1.0f);
 }
 
 /* ************************ Marker Wrappers API ********************* */
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index 56d5e37..3d0e29a 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -490,8 +490,8 @@ void draw_keyframe_shape(float x, float y, float xscale, float hsize, short sel,
 	hsize -= 0.5f * key_type;
 	
 	/* adjust view transform before starting */
-	gpuTranslate(x, y, 0.0f);
-	gpuScale(1.0f / xscale * hsize, hsize, 1.0f);
+	gpuTranslate(GPU_MODELVIEW, x, y, 0.0f);
+	gpuScale(GPU_MODELVIEW, 1.0f / xscale * hsize, hsize, 1.0f);
 	
 	/* anti-aliased lines for more consistent appearance */
 	glEnable(GL_LINE_SMOOTH);
@@ -555,8 +555,8 @@ void draw_keyframe_shape(float x, float y, float xscale, float hsize, short sel,
 	glDisable(GL_LINE_SMOOTH);
 	
 	/* restore view transform */
-	gpuScale(xscale / hsize, 1.0f / hsize, 1.0f);
-	gpuTranslate(-x, -y, 0.0f);
+	gpuScale(GPU_MODELVIEW, xscale / hsize, 1.0f / hsize, 1.0f);
+	gpuTranslate(GPU_MODELVIEW, -x, -y, 0.0f);
 }
 
 static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, float ypos, short channelLocked)
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c
index 600b409..3634210 100644
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ b/source/blender/editors/armature/editarmature_sketch.c
@@ -438,7 +438,7 @@ static float sk_clampPointSize(SK_Point *pt, float size)
 
 static void sk_drawPoint(struct GPUprim3 *prim, SK_Point *pt, float size)
 {
-	gpuTranslate(pt->p[0], pt->p[1], pt->p[2]);
+	gpuTranslate(GPU_MODELVIEW, pt->p[0], pt->p[1], pt->p[2]);
 	gpuDrawSphere(prim, sk_clampPointSize(pt, size));
 	//GLU gluSphere(quad, sk_clampPointSize(pt, size), 8, 8);
 }
@@ -458,7 +458,7 @@ static void sk_drawEdge(struct GPUprim3 *prim, SK_Point *pt0, SK_Point *pt1, flo
 
 	angle = angle_normalized_v3v3(vec2, vec1);
 
-	gpuRotateVector(angle * (float)(180.0 / M_PI) + 180.0f, axis);
+	gpuRotateVector(GPU_MODELVIEW, angle * (float)(180.0 / M_PI) + 180.0f, axis);
 
 	gpuDrawCylinder(prim, sk_clampPointSize(pt1, size), sk_clampPointSize(pt0, size), length);
 	//GLU Cylinder(quad, sk_clampPointSize(pt1, size), sk_clampPointSize(pt0, size), length, 8, 8);
@@ -469,7 +469,7 @@ static void sk_drawNormal(struct GPUprim3 *prim, SK_Point *pt, float size, float
 	float vec2[3] = {0, 0, 1}, axis[3];
 	float angle;
 	
-	gpuPushMatrix();
+	gpuPushMatrix(GPU_MODELVIEW);
 
 	cross_v3_v3v3(axis, vec2, pt->no);
 
@@ -479,14 +479,14 @@ static void sk_drawNormal(struct GPUprim3 *prim, SK_Point *pt, float size, float
 
 	angle = angle_normalized_v3v3(vec2, pt->no);
 
-	gpuRotateVector(angle * (float)(180.0 / M_PI), axis);
+	gpuRotateVector(GPU_MODELVIEW, angle * (float)(180.0 / M_PI), axis);
 
 	glColor3f(0, 1, 1);
 
 	gpuDrawCylinder(prim, sk_clampPointSize(pt, size), 0, sk_clampPointSize(pt, height));
 	//GLU Cylinder(quad, sk_clampPointSize(pt, size), 0, sk_clampPointSize(pt, height), 10, 2);
 
-	gpuPopMatrix();
+	gpuPopMatrix(GPU_MODELVIEW);
 }
 
 static void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int end)
@@ -499,7 +499,7 @@ static void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int
 		GPU_select_load_id(id);
 
 		for (i = 0; i < stk->nb_points; i++) {
-			gpuPushMatrix();
+			gpuPushMatrix(GPU_MODELVIEW);
 
 			sk_drawPoint(&prim, stk->points + i, 0.1);
 
@@ -507,7 +507,7 @@ static void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int
 				sk_drawEdge(&prim, stk->points + i - 1, stk->points + i, 0.1);
 			}
 
-			gpuPopMatrix();
+			gpuPopMatrix(GPU_MODELVIEW);
 		}
 
 	}
@@ -521,7 +521,7 @@ static void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int
 		for (i = 0; i < stk->nb_points; i++) {
 			SK_Point *pt = stk->points + i;
 
-			gpuPushMatrix();
+			gpuPushMatrix(GPU_MODELVIEW);
 
 			if (pt->type == PT_EXACT) {
 				glColor3f(0, 0, 0);
@@ -545,7 +545,7 @@ static void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int
 				sk_drawEdge(&prim, pt - 1, pt, 0.1);
 			}
 
-			gpuPopMatrix();
+			gpuPopMatrix(GPU_MODELVIEW);
 
 			add_v3_v3(rgb, d_rgb);
 		}
@@ -569,14 +569,14 @@ static void drawSubdividedStrokeBy(ToolSettings *toolsettings, BArcIterator *ite
 	while (index != -1) {
 		SK_Point *pt = stk->points + index;
 
-		gpuPushMatrix();
+		gpuPushMatrix(GPU_MODELVIEW);
 
 		glColor3f(0, 1, 0);
 		sk_drawPoint(&prim, pt, 0.15);
 
 		sk_drawNormal(&prim, pt, 0.05, 0.9);
 
-		gpuPopMatrix();
+		gpuPopMatrix(GPU_MODELVIEW);
 
 		copy_v3_v3(head, tail);
 		bone_start = index; // start next bone from current index
@@ -2060,7 +2060,7 @@ static void sk_drawSketch(Scen

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list