[Bf-blender-cvs] [6d2aca5a96] blender2.8: OpenGL: convert to new matrix API (part 5)

Mike Erwin noreply at git.blender.org
Tue Mar 21 22:51:34 CET 2017


Commit: 6d2aca5a96efd8ac61eec633c43a41e641379a68
Author: Mike Erwin
Date:   Tue Mar 21 17:49:21 2017 -0400
Branches: blender2.8
https://developer.blender.org/rB6d2aca5a96efd8ac61eec633c43a41e641379a68

OpenGL: convert to new matrix API (part 5)

Pretty sure source/blender is now finished, with all legacy matrix calls confined to gpu_matrix.c.

This was the easy part, but doing it first makes the next part much easier. TODO and XXX notes describe what is left.

glMatrixMode is still in place, since the new API does not share this concept of modes. Similar for glOrtho and glFrustum which I'll tackle very soon.

Part of T49450

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

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/interface/view2d.c
M	source/blender/editors/mesh/editmesh_knife.c
M	source/blender/editors/screen/glutil.c
M	source/blender/editors/sculpt_paint/paint_utils.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_view3d/drawanimviz.c
M	source/blender/editors/space_view3d/drawmesh.c
M	source/blender/editors/space_view3d/drawsimdebug.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_generics.c
M	source/blender/windowmanager/intern/wm_subwindow.c

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

diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index ab7c831f95..17b353d48c 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -555,7 +555,7 @@ static void blf_draw_gl__start(FontBLF *font)
 	gpuMatrixBegin3D_legacy();
 
 	if (font->flags & BLF_MATRIX)
-		gpuMultMatrix3D((float (*)[4])font->m);
+		gpuMultMatrix3D(font->m);
 
 	gpuTranslate3fv(font->pos);
 
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 6b7fe00dba..ad4678d8ee 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -51,6 +51,7 @@
 #include "GPU_texture.h"
 #include "GPU_uniformbuffer.h"
 #include "GPU_viewport.h"
+#include "GPU_matrix.h"
 
 #include "RE_engine.h"
 
@@ -1067,9 +1068,9 @@ void DRW_draw_callbacks_pre_scene(void)
 	/* This is temporary
 	 * waiting for the full matrix switch */
 	glMatrixMode(GL_PROJECTION);
-	glLoadMatrixf((float *)rv3d->winmat);
+	gpuLoadMatrix3D(rv3d->winmat);
 	glMatrixMode(GL_MODELVIEW);
-	glLoadMatrixf((float *)rv3d->viewmat);
+	gpuLoadMatrix3D(rv3d->viewmat);
 
 	ED_region_draw_cb_draw(DST.context, ar, REGION_DRAW_PRE_VIEW);
 }
@@ -1082,9 +1083,9 @@ void DRW_draw_callbacks_post_scene(void)
 	/* This is temporary
 	 * waiting for the full matrix switch */
 	glMatrixMode(GL_PROJECTION);
-	glLoadMatrixf((float *)rv3d->winmat);
+	gpuLoadMatrix3D(rv3d->winmat);
 	glMatrixMode(GL_MODELVIEW);
-	glLoadMatrixf((float *)rv3d->viewmat);
+	gpuLoadMatrix3D(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 747cc84a9c..e0a19cec7a 100644
--- a/source/blender/draw/intern/draw_view.c
+++ b/source/blender/draw/intern/draw_view.c
@@ -532,9 +532,9 @@ void DRW_draw_grid(void)
 		drawgrid(&scene->unit, ar, v3d, &grid_unit);
 
 		glMatrixMode(GL_PROJECTION);
-		glLoadMatrixf((float *)rv3d->winmat);
+		gpuLoadMatrix3D(rv3d->winmat);
 		glMatrixMode(GL_MODELVIEW);
-		glLoadMatrixf((float *)rv3d->viewmat);
+		gpuLoadMatrix3D(rv3d->viewmat);
 	}
 	else {
 		glDepthMask(GL_TRUE);
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 5c2d4cafd8..5a9a4ef49e 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -50,11 +50,10 @@
 #include "BKE_global.h"
 
 #include "GPU_immediate.h"
+#include "GPU_matrix.h"
 
 #include "WM_api.h"
 
-#include "BIF_gl.h"
-
 #include "BLF_api.h"
 
 #include "ED_screen.h"
@@ -1139,7 +1138,7 @@ void UI_view2d_view_restore(const bContext *C)
 	int height = BLI_rcti_size_y(&ar->winrct) + 1;
 	
 	wmOrtho2(0.0f, (float)width, 0.0f, (float)height);
-	glLoadIdentity();
+	gpuLoadIdentity();
 	
 	//	ED_region_pixelspace(CTX_wm_region(C));
 }
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index f320943d68..a7fa5eb813 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -54,10 +54,10 @@
 #include "BKE_editmesh_bvh.h"
 #include "BKE_report.h"
 
-#include "BIF_gl.h"
 #include "BIF_glutil.h" /* for paint cursor */
 
 #include "GPU_immediate.h"
+#include "GPU_matrix.h"
 
 #include "ED_screen.h"
 #include "ED_space_api.h"
@@ -1043,8 +1043,8 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
 
 	glPolygonOffset(1.0f, 1.0f);
 
-	glPushMatrix();
-	glMultMatrixf(kcd->ob->obmat);
+	gpuPushMatrix();
+	gpuMultMatrix3D(kcd->ob->obmat);
 
 	unsigned pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 3, KEEP_FLOAT);
 
@@ -1191,7 +1191,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
 
 	immUnbindProgram();
 
-	glPopMatrix();
+	gpuPopMatrix();
 
 	if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
 }
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index f077535f51..0834f05706 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -623,8 +623,8 @@ gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect)
 
 	glGetIntegerv(GL_VIEWPORT, (GLint *)di->orig_vp);
 	glGetIntegerv(GL_SCISSOR_BOX, (GLint *)di->orig_sc);
-	glGetFloatv(GL_PROJECTION_MATRIX, (GLfloat *)di->orig_projmat);
-	glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat *)di->orig_viewmat);
+	gpuGetProjectionMatrix3D(di->orig_projmat);
+	gpuGetModelViewMatrix3D(di->orig_viewmat);
 
 	di->screen_rect = *screen_rect;
 	if (world_rect) {
@@ -703,7 +703,7 @@ void bglPolygonOffset(float viewdist, float dist)
 
 		/* hack below is to mimic polygon offset */
 		glMatrixMode(GL_PROJECTION);
-		glGetFloatv(GL_PROJECTION_MATRIX, (float *)winmat);
+		gpuGetProjectionMatrix3D(winmat);
 		
 		/* dist is from camera to center point */
 		
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index 756536f3db..23c0f680a6 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -59,8 +59,7 @@
 #include "RNA_access.h"
 #include "RNA_define.h"
 
-#include "BIF_gl.h"
-#include "BIF_glutil.h"
+#include "GPU_matrix.h"
 
 #include "IMB_colormanagement.h"
 #include "IMB_imbuf_types.h"
@@ -285,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);
-	glGetFloatv(GL_MODELVIEW_MATRIX,  (float *)matrix);
-	glGetFloatv(GL_PROJECTION_MATRIX, (float *)proj);
+	gpuGetModelViewMatrix3D(matrix);
+	gpuGetProjectionMatrix3D(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_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 940d6f0701..d525886996 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -852,7 +852,7 @@ void draw_image_main(const bContext *C, ARegion *ar)
 			calc_image_view(sima, 'f');
 			myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
 			glRectf(0.0f, 0.0f, 1.0f, 1.0f);
-			glLoadIdentity();
+			gpuLoadIdentity();
 		}
 	}
 #endif
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 6796802dca..51b82c9f42 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -50,11 +50,11 @@
 #include "BLF_api.h"
 #include "BLT_translation.h"
 
-#include "BIF_gl.h"
 #include "BIF_glutil.h"
 
 #include "GPU_draw.h"
 #include "GPU_immediate.h"
+#include "GPU_matrix.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -3198,9 +3198,9 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
 		float x, y; 
 		
 		glMatrixMode(GL_PROJECTION);
-		glPushMatrix();
+		gpuPushMatrix();
 		glMatrixMode(GL_MODELVIEW);
-		glPushMatrix();
+		gpuPushMatrix();
 		
 		/* somehow the offset has to be calculated inverse */
 		
@@ -3286,9 +3286,9 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
 		}
 		
 		glMatrixMode(GL_PROJECTION);
-		glPopMatrix();
+		gpuPopMatrix();
 		glMatrixMode(GL_MODELVIEW);
-		glPopMatrix();
+		gpuPopMatrix();
 	}
 	
 	BKE_image_release_ibuf(ima, ibuf, lock);
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 3da0150a75..36aa3358b1 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -58,6 +58,7 @@
 #include "BIF_glutil.h"
 
 #include "GPU_immediate.h"
+#include "GPU_matrix.h"
 
 #include "ED_anim_api.h"
 #include "ED_gpencil.h"
@@ -1287,11 +1288,11 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
 
 	if (draw_backdrop) {
 		glMatrixMode(GL_PROJECTION);
-		glPushMatrix();
-		glLoadIdentity();
+		gpuPushMatrix();
+		gpuLoadIdentity();
 		glMatrixMode(GL_MODELVIEW);
-		glPushMatrix();
-		glLoadIdentity();
+		gpuPushMatrix();
+		gpuLoadIdentity();
 	}
 
 	glGenTextures(1, (GLuint *)&texid);
@@ -1420,9 +1421,9 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
 	}
 
 	if (draw_backdrop) {
-		glPopMatrix();
+		gpuPopMatrix();
 		glMatrixMode(GL_PROJECTION);
-		glPopMatrix();
+		gpuPopMatrix();
 		glMatrixMode(GL_MODELVIEW);
 		return;
 	}
diff --git a/source/blender/editors/space_view3d/drawanimviz.c b/source/blender/editors/space_view3d/drawanimviz.c
index 505ed1fdd3..7ab2b4ec3a 100644
--- a/source/blender/editors/space_view3d/drawanimviz.c
+++ b/source/blender/editors/space_view3d/drawanimviz.c
@@ -49,9 +49,8 @@
 #include "BKE_animsys.h"
 #include "BKE_action.h"
 
-#include "BIF_gl.h"
-
 #include "GPU_immediate.h"
+#include "GPU_matrix.h"
 
 #include "ED_keyframes_draw.h"
 
@@ -73,8 +72,8 @@ void draw_motion_paths_init(View3D *v3d, ARegion *ar)
 	
 	if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
 	
-	glPushMatrix();
-	glLoadMatrixf(rv3d->viewmat);
+	gpuPushMatrix();
+	gpuLoadMatrix3D(rv3d->viewmat);
 }
 
 /* set color
@@ -435,5 +434,5 @@ void draw_motion_path_instance(Scene *scene,
 void draw_motion_paths_cleanup(View3D *v3d)
 {
 	if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
-	glPopMatrix();
+	gpuPopMatrix();
 }
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index 8cd03a2aac..102a754e6d 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -55,7 +55,6 @@
 #include "BKE_editmesh.h"
 #include "BKE_scene.h"
 
-#include "BIF_gl.h"
 #include "BIF_glutil.h"
 
 #include "UI_resources.h"
@@ -64,6 +63,7 @@
 #include "GPU_material.h"
 #include "GPU_basic_shader.h"
 #include "GPU_shader.h"
+#include "GPU_matrix.h"
 
 #include "RE_engine.h"
 
@@ -547,10 +547,10 @@ static void draw_textured_end(void)
 	 * of and restored the light settings it changed.
 	 *  - zr
 	 */
-	glPushMatrix();
-	glLoadIdentity();
+	

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list