[Bf-blender-cvs] [4b043994e87] blender2.8: GPU Matrix API: clean up after 2D-3D unification

Mike Erwin noreply at git.blender.org
Sat Apr 15 07:31:36 CEST 2017


Commit: 4b043994e8795f37e9227362fe24fd66d45c6b39
Author: Mike Erwin
Date:   Sat Apr 15 01:29:25 2017 -0400
Branches: blender2.8
https://developer.blender.org/rB4b043994e8795f37e9227362fe24fd66d45c6b39

GPU Matrix API: clean up after 2D-3D unification

See GPU_matrix.h & gpu_matrix.c for the important changes. Other files are mostly just updated to use the latest API.

- remove unused functions, defines, enums, comments
- remove "3D" from function names
- init to Identity transform (otherwise empty stack)
- gpuMatrixReset lets outside code return to initial state

Part of T49450
Follow up to D2626 and 49fc9cff3b90

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

M	source/blender/blenfont/intern/blf.c
M	source/blender/draw/intern/draw_manager.c
M	source/blender/draw/intern/draw_view.c
M	source/blender/editors/curve/editcurve_paint.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/screen/glutil.c
M	source/blender/editors/sculpt_paint/paint_utils.c
M	source/blender/editors/space_clip/clip_draw.c
M	source/blender/editors/space_clip/space_clip.c
M	source/blender/editors/space_view3d/drawanimviz.c
M	source/blender/editors/space_view3d/drawarmature.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_draw_legacy.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_generics.c
M	source/blender/gpu/GPU_matrix.h
M	source/blender/gpu/intern/gpu_draw.c
M	source/blender/gpu/intern/gpu_matrix.c
M	source/blender/windowmanager/intern/wm_subwindow.c
M	source/blender/windowmanager/manipulators/intern/manipulator_library/arrow_manipulator.c
M	source/blender/windowmanager/manipulators/intern/manipulator_library/dial_manipulator.c
M	source/blender/windowmanager/manipulators/intern/manipulator_library/primitive_manipulator.c

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

diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 663be49c71e..e6dffedc5d9 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -555,15 +555,15 @@ static void blf_draw_gl__start(FontBLF *font)
 	gpuPushMatrix();
 
 	if (font->flags & BLF_MATRIX)
-		gpuMultMatrix3D(font->m);
+		gpuMultMatrix(font->m);
 
 	gpuTranslate3fv(font->pos);
 
 	if (font->flags & BLF_ASPECT)
 		gpuScale3fv(font->aspect);
 
-	if (font->flags & BLF_ROTATION)  /* radians -> degrees */
-		gpuRotateAxis(RAD2DEG(font->angle), 'Z'); /* TODO: use gpuRotate2D here? */
+	if (font->flags & BLF_ROTATION)
+		gpuRotate2D(RAD2DEG(font->angle));
 
 #ifndef BLF_STANDALONE
 	VertexFormat *format = immVertexFormat();
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 65daf347443..b0864f5ed9a 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -1157,8 +1157,8 @@ void DRW_draw_callbacks_pre_scene(void)
 	struct ARegion *ar = CTX_wm_region(DST.context);
 	RegionView3D *rv3d = CTX_wm_region_view3d(DST.context);
 
-	gpuLoadProjectionMatrix3D(rv3d->winmat);
-	gpuLoadMatrix3D(rv3d->viewmat);
+	gpuLoadProjectionMatrix(rv3d->winmat);
+	gpuLoadMatrix(rv3d->viewmat);
 
 	ED_region_draw_cb_draw(DST.context, ar, REGION_DRAW_PRE_VIEW);
 }
@@ -1168,8 +1168,8 @@ void DRW_draw_callbacks_post_scene(void)
 	struct ARegion *ar = CTX_wm_region(DST.context);
 	RegionView3D *rv3d = CTX_wm_region_view3d(DST.context);
 
-	gpuLoadProjectionMatrix3D(rv3d->winmat);
-	gpuLoadMatrix3D(rv3d->viewmat);
+	gpuLoadProjectionMatrix(rv3d->winmat);
+	gpuLoadMatrix(rv3d->viewmat);
 
 	ED_region_draw_cb_draw(DST.context, ar, REGION_DRAW_POST_VIEW);
 }
diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c
index f5ddd05e915..66542e221b1 100644
--- a/source/blender/draw/intern/draw_view.c
+++ b/source/blender/draw/intern/draw_view.c
@@ -534,8 +534,8 @@ void DRW_draw_grid(void)
 		*(&grid_unit) = NULL;  /* drawgrid need this to detect/affect smallest valid unit... */
 		drawgrid(&scene->unit, ar, v3d, &grid_unit);
 
-		gpuLoadProjectionMatrix3D(rv3d->winmat);
-		gpuLoadMatrix3D(rv3d->viewmat);
+		gpuLoadProjectionMatrix(rv3d->winmat);
+		gpuLoadMatrix(rv3d->viewmat);
 	}
 	else {
 		glDepthMask(GL_TRUE);
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index eb6e3074cab..804d5573993 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -476,7 +476,7 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
 
 		/* scale to edit-mode space */
 		gpuPushMatrix();
-		gpuMultMatrix3D(obedit->obmat);
+		gpuMultMatrix(obedit->obmat);
 
 		BLI_mempool_iternew(cdd->stroke_elem_pool, &iter);
 		for (selem = BLI_mempool_iterstep(&iter); selem; selem = BLI_mempool_iterstep(&iter)) {
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index c4f62fdaf97..228a4db74e1 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -767,7 +767,7 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar,
 		gpuTranslate2f(x, y);
 		gpuScale2f(zoomx, zoomy);
 		if (stabmat) {
-			gpuMultMatrix3D(stabmat); /* XXX make this a 2D matrix */
+			gpuMultMatrix(stabmat);
 		}
 		IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
 		GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, red);
@@ -786,7 +786,7 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar,
 	gpuPushMatrix();
 
 	if (stabmat) {
-		gpuMultMatrix3D(stabmat); /* XXX make this a 2D matrix */
+		gpuMultMatrix(stabmat);
 	}
 
 	gpuTranslate2f(x + xofs, y + yofs);
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 1afa676a0f9..3fe7c1d1c99 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -1042,7 +1042,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
 	glPolygonOffset(1.0f, 1.0f);
 
 	gpuPushMatrix();
-	gpuMultMatrix3D(kcd->ob->obmat);
+	gpuMultMatrix(kcd->ob->obmat);
 
 	unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
 
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index c6a3e29bad1..e7a6689b57c 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -106,7 +106,7 @@ static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
 			glDisable(GL_DEPTH_TEST);
 
 		gpuPushMatrix();
-		gpuMultMatrix3D(lcd->ob->obmat);
+		gpuMultMatrix(lcd->ob->obmat);
 
 		unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
 
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index a54bd8a290a..43f77a7d5b5 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -367,18 +367,8 @@ void glaDefine2DArea(rcti *screen_rect)
 	 * Programming Guide, Appendix H, Correctness Tips.
 	 */
 
-#if 1 /* new style */
 	gpuOrtho2D(GLA_PIXEL_OFS, sc_w + GLA_PIXEL_OFS, GLA_PIXEL_OFS, sc_h + GLA_PIXEL_OFS);
 	gpuLoadIdentity();
-#else /* original */
-	glMatrixMode(GL_PROJECTION);
-	gpuLoadIdentity();
-	glOrtho(0.0, sc_w, 0.0, sc_h, -1, 1);
-	gpuTranslate2f(GLA_PIXEL_OFS, GLA_PIXEL_OFS);
-
-	glMatrixMode(GL_MODELVIEW);
-	gpuLoadIdentity();
-#endif
 }
 
 /* TODO(merwin): put the following 2D code to use, or build new 2D code inspired & informd by it */
@@ -436,8 +426,8 @@ gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect)
 
 	glGetIntegerv(GL_VIEWPORT, (GLint *)di->orig_vp);
 	glGetIntegerv(GL_SCISSOR_BOX, (GLint *)di->orig_sc);
-	gpuGetProjectionMatrix3D(di->orig_projmat);
-	gpuGetModelViewMatrix3D(di->orig_viewmat);
+	gpuGetProjectionMatrix(di->orig_projmat);
+	gpuGetModelViewMatrix(di->orig_viewmat);
 
 	di->screen_rect = *screen_rect;
 	if (world_rect) {
@@ -488,8 +478,8 @@ void glaEnd2DDraw(gla2DDrawInfo *di)
 {
 	glViewport(di->orig_vp[0], di->orig_vp[1], di->orig_vp[2], di->orig_vp[3]);
 	glScissor(di->orig_vp[0], di->orig_vp[1], di->orig_vp[2], di->orig_vp[3]);
-	gpuLoadProjectionMatrix3D(di->orig_projmat);
-	gpuLoadMatrix3D(di->orig_viewmat);
+	gpuLoadProjectionMatrix(di->orig_projmat);
+	gpuLoadMatrix(di->orig_viewmat);
 
 	MEM_freeN(di);
 }
@@ -513,7 +503,7 @@ void bglPolygonOffset(float viewdist, float dist)
 		// glPolygonOffset(-1.0, -1.0);
 
 		/* hack below is to mimic polygon offset */
-		gpuGetProjectionMatrix3D((float (*)[4])winmat);
+		gpuGetProjectionMatrix(winmat);
 		
 		/* dist is from camera to center point */
 		
@@ -550,7 +540,7 @@ void bglPolygonOffset(float viewdist, float dist)
 		offset = 0.0;
 	}
 
-	gpuLoadProjectionMatrix3D((const float (*)[4])winmat);
+	gpuLoadProjectionMatrix(winmat);
 }
 
 /* **** Color management helper functions for GLSL display/transform ***** */
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index 7c3aca80ada..e36cc275ba9 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -284,8 +284,8 @@ static void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, c
 
 	/* get the needed opengl matrices */
 	glGetIntegerv(GL_VIEWPORT, view);
-	gpuGetModelViewMatrix3D(matrix);
-	gpuGetProjectionMatrix3D(proj);
+	gpuGetModelViewMatrix(matrix);
+	gpuGetProjectionMatrix(proj);
 	view[0] = view[1] = 0;
 	mul_m4_m4m4(matrix, matrix, ob->obmat);
 	mul_m4_m4m4(matrix, proj, matrix);
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index 0986a4bc4a7..dfedfa5bc12 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -357,7 +357,7 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int
 		gpuTranslate2f(x, y);
 
 		gpuScale2f(zoomx, zoomy);
-		gpuMultMatrix3D(sc->stabmat); /* XXX can we make stabmat a 2D matrix? --merwin */
+		gpuMultMatrix(sc->stabmat);
 
 		unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
 
@@ -1079,7 +1079,7 @@ static void draw_plane_marker_image(Scene *scene,
 			                                          plane_marker->corners,
 			                                          perspective_matrix);
 
-			homogeneous_2d_to_gl_matrix(perspective_matrix, gl_matrix); /* XXX update for new 2D matrix API --merwin */
+			homogeneous_2d_to_gl_matrix(perspective_matrix, gl_matrix);
 
 			if (plane_track->image_opacity != 1.0f || ibuf->planes == 32) {
 				transparent = true;
@@ -1098,7 +1098,7 @@ static void draw_plane_marker_image(Scene *scene,
 			             GL_UNSIGNED_BYTE, display_buffer);
 
 			gpuPushMatrix();
-			gpuMultMatrix3D(gl_matrix); /* XXX update for new 2D matrix API --merwin */
+			gpuMultMatrix(gl_matrix);
 
 			VertexFormat *imm_format = immVertexFormat();
 			unsigned int pos = VertexFormat_add_attrib(imm_format, "pos", COMP_F32, 2, KEEP_FLOAT);
@@ -1296,7 +1296,7 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie
 
 	gpuPushMatrix();
 	gpuScale2f(zoomx, zoomy);
-	gpuMultMatrix3D(sc->stabmat); /* XXX would like 2D stabmat --merwin */
+	gpuMultMatrix(sc->stabmat);
 	gpuScale2f(width, height);
 
 	act_track = BKE_tracking_track_get_active(tracking);
@@ -1544,7 +1544,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
 	gpuPushMatrix();
 	gpuTranslate2f(x, y);
 	gpuScale2f(zoomx, zoomy);
-	gpuMultMatrix3D(sc->stabmat); /* XXX make 2D */
+	gpuMultMatrix(sc->stabmat);
 	gpuScale2f(width, height);
 
 	unsigned int position = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
@@ -1821,7 +1821,7 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d)
 		 */
 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list