[Bf-blender-cvs] [d409c48310] blender2.8: OpenGL: convert to new matrix API (part 3)

Mike Erwin noreply at git.blender.org
Tue Mar 21 07:52:53 CET 2017


Commit: d409c483104c36be82ff29ff06a39b40636355dc
Author: Mike Erwin
Date:   Tue Mar 21 02:51:02 2017 -0400
Branches: blender2.8
https://developer.blender.org/rBd409c483104c36be82ff29ff06a39b40636355dc

OpenGL: convert to new matrix API (part 3)

Part of T49450

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

M	source/blender/editors/screen/area.c
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/editors/space_view3d/view3d_draw_legacy.c
M	source/blender/gpu/intern/gpu_draw.c
M	source/blender/gpu/intern/gpu_framebuffer.c
M	source/blender/windowmanager/intern/wm_operators.c
M	source/blender/windowmanager/intern/wm_playanim.c

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

diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 7e1fda6d09..0d3a060b8e 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -58,9 +58,9 @@
 #include "ED_space_api.h"
 
 #include "GPU_immediate.h"
+#include "GPU_matrix.h"
 #include "GPU_draw.h"
 
-#include "BIF_gl.h"
 #include "BIF_glutil.h"
 #include "BLF_api.h"
 
@@ -123,7 +123,7 @@ static void region_draw_emboss(const ARegion *ar, const rcti *scirct)
 void ED_region_pixelspace(ARegion *ar)
 {
 	wmOrtho2_region_pixelspace(ar);
-	glLoadIdentity();
+	gpuLoadIdentity();
 }
 
 /* only exported for WM */
@@ -455,8 +455,8 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar)
 	glEnable(GL_BLEND);
 	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
-	glPushMatrix();
-	glTranslatef(-ar->winrct.xmin, -ar->winrct.ymin, 0.0f);
+	gpuPushMatrix();
+	gpuTranslate2f(-ar->winrct.xmin, -ar->winrct.ymin);
 	
 	for (az = sa->actionzones.first; az; az = az->next) {
 		/* test if action zone is over this region */
@@ -493,7 +493,7 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar)
 		}
 	}
 
-	glPopMatrix();
+	gpuPopMatrix();
 
 	glDisable(GL_BLEND);
 }
@@ -2338,11 +2338,11 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame,
 		return;
 
 	/* find window pixel coordinates of origin */
-	glPushMatrix();
+	gpuPushMatrix();
 
 	/* offset and zoom using ogl */
-	glTranslatef(x, y, 0.0f);
-	glScalef(zoomx, zoomy, 1.0f);
+	gpuTranslate2f(x, y);
+	gpuScale2f(zoomx, zoomy);
 
 	BLF_size(blf_mono_font, style->widgetlabel.points * 1.5f * U.pixelsize, U.dpi);
 
@@ -2396,7 +2396,7 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame,
 		BLF_disable(blf_mono_font, BLF_CLIPPING);
 	}
 
-	glPopMatrix();
+	gpuPopMatrix();
 }
 
 void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy)
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index e1eaf2e172..2fa154015f 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -207,11 +207,10 @@ static void view3d_main_region_setup_view(Scene *scene, View3D *v3d, ARegion *ar
 	ED_view3d_update_viewmat(scene, v3d, ar, viewmat, winmat);
 
 	/* set for opengl */
-	/* TODO(merwin): transition to GPU_matrix API */
 	glMatrixMode(GL_PROJECTION);
-	glLoadMatrixf(rv3d->winmat);
+	gpuLoadMatrix3D(rv3d->winmat); /* XXX make a gpuLoadProjectionMatrix function? */
 	glMatrixMode(GL_MODELVIEW);
-	glLoadMatrixf(rv3d->viewmat);
+	gpuLoadMatrix3D(rv3d->viewmat);
 }
 
 static bool view3d_stereo3d_active(const bContext *C, Scene *scene, View3D *v3d, RegionView3D *rv3d)
@@ -773,9 +772,9 @@ static bool view3d_draw_render_draw(const bContext *C, Scene *scene,
 
 	/* background draw */
 	glMatrixMode(GL_PROJECTION);
-	glPushMatrix();
+	gpuPushMatrix();
 	glMatrixMode(GL_MODELVIEW);
-	glPushMatrix();
+	gpuPushMatrix();
 	ED_region_pixelspace(ar);
 
 	if (clip_border) {
@@ -804,9 +803,9 @@ static bool view3d_draw_render_draw(const bContext *C, Scene *scene,
 	}
 
 	glMatrixMode(GL_PROJECTION);
-	glPopMatrix();
+	gpuPopMatrix();
 	glMatrixMode(GL_MODELVIEW);
-	glPopMatrix();
+	gpuPopMatrix();
 
 	return true;
 }
@@ -1498,9 +1497,9 @@ static void view3d_draw_grid(const bContext *C, ARegion *ar)
 		drawgrid(&scene->unit, ar, v3d, &grid_unit);
 
 		glMatrixMode(GL_PROJECTION);
-		glLoadMatrixf(rv3d->winmat);
+		gpuLoadMatrix3D(rv3d->winmat); /* XXX make a gpuLoadProjectionMatrix function? */
 		glMatrixMode(GL_MODELVIEW);
-		glLoadMatrixf(rv3d->viewmat);
+		gpuLoadMatrix3D(rv3d->viewmat);
 	}
 	else {
 		drawfloor(scene, v3d, &grid_unit, false);
@@ -1786,9 +1785,9 @@ Scene *scene, SceneLayer *sl, Object *ob, Base *base, View3D *v3d,
 RegionView3D *rv3d, const bool is_boundingbox, const unsigned char color[4])
 {
 	glMatrixMode(GL_PROJECTION);
-	glPushMatrix();
+	gpuPushMatrix();
 	glMatrixMode(GL_MODELVIEW);
-	glPushMatrix();
+	gpuPushMatrix();
 
 	/* multiply view with object matrix.
 	* local viewmat and persmat, to calculate projections */
@@ -1834,9 +1833,9 @@ RegionView3D *rv3d, const bool is_boundingbox, const unsigned char color[4])
 	ED_view3d_clear_mats_rv3d(rv3d);
 
 	glMatrixMode(GL_PROJECTION);
-	glPopMatrix();
+	gpuPopMatrix();
 	glMatrixMode(GL_MODELVIEW);
-	glPopMatrix();
+	gpuPopMatrix();
 }
 
 /* ******************** info ***************** */
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index f7896de128..43e6742061 100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@ -76,7 +76,6 @@
 #include "IMB_imbuf.h"
 #include "IMB_colormanagement.h"
 
-#include "BIF_gl.h"
 #include "BIF_glutil.h"
 
 #include "WM_api.h"
@@ -103,6 +102,7 @@
 #include "GPU_extensions.h"
 #include "GPU_immediate.h"
 #include "GPU_select.h"
+#include "GPU_matrix.h"
 
 #include "view3d_intern.h"  /* own include */
 
@@ -752,13 +752,13 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
 			glBlendFunc(GL_SRC_ALPHA,  GL_ONE_MINUS_SRC_ALPHA);
 
 			glMatrixMode(GL_PROJECTION);
-			glPushMatrix();
+			gpuPushMatrix();
 			glMatrixMode(GL_MODELVIEW);
-			glPushMatrix();
+			gpuPushMatrix();
 			ED_region_pixelspace(ar);
 
-			glTranslatef(centx, centy, 0.0);
-			glRotatef(RAD2DEGF(-bgpic->rotation), 0.0f, 0.0f, 1.0f);
+			gpuTranslate2f(centx, centy);
+			gpuRotate2D(RAD2DEGF(-bgpic->rotation));
 
 			if (bgpic->flag & V3D_BGPIC_FLIP_X) {
 				zoomx *= -1.0f;
@@ -775,9 +775,9 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
 			                 zoomx, zoomy, col);
 
 			glMatrixMode(GL_PROJECTION);
-			glPopMatrix();
+			gpuPopMatrix();
 			glMatrixMode(GL_MODELVIEW);
-			glPopMatrix();
+			gpuPopMatrix();
 
 			glDisable(GL_BLEND);
 
@@ -1190,7 +1190,7 @@ void ED_view3d_draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d)
 
 	glClear(GL_DEPTH_BUFFER_BIT);
 
-	glLoadMatrixf(rv3d->viewmat);
+	gpuLoadMatrix3D(rv3d->viewmat);
 
 	v3d->zbuf = true;
 	glEnable(GL_DEPTH_TEST);
@@ -1228,7 +1228,7 @@ void ED_view3d_draw_depth(Scene *scene, ARegion *ar, View3D *v3d, bool alphaover
 	
 	glClear(GL_DEPTH_BUFFER_BIT);
 	
-	glLoadMatrixf(rv3d->viewmat);
+	gpuLoadMatrix3D(rv3d->viewmat);
 	
 	if (rv3d->rflag & RV3D_CLIPPING) {
 		ED_view3d_clipping_set(rv3d);
@@ -1586,9 +1586,9 @@ static void view3d_draw_objects(
 			VP_legacy_drawgrid(&scene->unit, ar, v3d, grid_unit);
 			/* XXX make function? replaces persp(1) */
 			glMatrixMode(GL_PROJECTION);
-			glLoadMatrixf(rv3d->winmat);
+			gpuLoadMatrix3D(rv3d->winmat); /* XXX make a gpuLoadProjectionMatrix function? */
 			glMatrixMode(GL_MODELVIEW);
-			glLoadMatrixf(rv3d->viewmat);
+			gpuLoadMatrix3D(rv3d->viewmat);
 		}
 		else if (!draw_grids_after) {
 			VP_legacy_drawfloor(scene, v3d, grid_unit, true);
@@ -1798,7 +1798,7 @@ void ED_view3d_draw_offscreen(
 	bool do_compositing = false;
 	RegionView3D *rv3d = ar->regiondata;
 
-	glPushMatrix();
+	gpuPushMatrix();
 
 	/* set temporary new size */
 	int bwinx = ar->winx;
@@ -1884,7 +1884,7 @@ void ED_view3d_draw_offscreen(
 	ar->winy = bwiny;
 	ar->winrct = brect;
 
-	glPopMatrix();
+	gpuPopMatrix();
 
 	UI_Theme_Restore(&theme_state);
 
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index e1d9e78c0b..d02759160e 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -78,6 +78,7 @@
 #include "GPU_draw.h"
 #include "GPU_extensions.h"
 #include "GPU_material.h"
+#include "GPU_matrix.h"
 #include "GPU_shader.h"
 #include "GPU_texture.h"
 
@@ -155,12 +156,12 @@ void GPU_render_text(
 			character = BLI_str_utf8_as_unicode_and_size_safe(textstr + index, &index);
 			
 			if (character == '\n') {
-				glTranslatef(line_start, -line_height, 0.0f);
+				gpuTranslate2f(line_start, -line_height);
 				line_start = 0.0f;
 				continue;
 			}
 			else if (character == '\t') {
-				glTranslatef(advance_tab, 0.0f, 0.0f);
+				gpuTranslate2f(advance_tab, 0.0f);
 				line_start -= advance_tab; /* so we can go back to the start of the line */
 				continue;
 				
@@ -209,10 +210,10 @@ void GPU_render_text(
 			}
 			glEnd();
 
-			glTranslatef(advance, 0.0f, 0.0f);
+			gpuTranslate2f(advance, 0.0f);
 			line_start -= advance; /* so we can go back to the start of the line */
 		}
-		glPopMatrix();
+		gpuPopMatrix();
 
 		BKE_image_release_ibuf(ima, first_ibuf, NULL);
 	}
@@ -419,7 +420,7 @@ void GPU_clear_tpage(bool force)
 	GTS.curima = NULL;
 	if (GTS.curtilemode != 0) {
 		glMatrixMode(GL_TEXTURE);
-		glLoadIdentity();
+		gpuLoadIdentity();
 		glMatrixMode(GL_MODELVIEW);
 	}
 	GTS.curtilemode = 0;
@@ -603,10 +604,10 @@ int GPU_verify_image(
 	    GTS.curtileYRep != GTS.tileYRep)
 	{
 		glMatrixMode(GL_TEXTURE);
-		glLoadIdentity();
+		gpuLoadIdentity();
 
 		if (ima && (ima->tpageflag & IMA_TILES))
-			glScalef(ima->xrep, ima->yrep, 1.0f);
+			gpuScale2f(ima->xrep, ima->yrep);
 
 		glMatrixMode(GL_MODELVIEW);
 	}
@@ -2095,7 +2096,7 @@ void GPU_end_object_materials(void)
 	/* resetting the texture matrix after the scaling needed for tiled textures */
 	if (GTS.tilemode) {
 		glMatrixMode(GL_TEXTURE);
-		glLoadIdentity();
+		gpuLoadIdentity();
 		glMatrixMode(GL_MODELVIEW);
 	}
 }
@@ -2172,8 +2173,8 @@ int GPU_scene_object_lights(Scene *scene, Object *ob, int lay, float viewmat[4][
 		Lamp *la = base->object->data;
 		
 		/* setup lamp transform */
-		glPushMatrix();
-		glLoadMatrixf((float *)viewmat);
+		gpuPushMatrix();
+		gpuLoadMatrix3D(viewmat);
 		
 		/* setup light */
 		GPULightData light = {0};
@@ -2207,7 +2208,7 @@ int GPU_scene_object_lights(Scene *scene, Object *ob, int lay, float viewmat[4][
 		
 		GPU_basic_shader_light_set(count, &light);
 		
-		glPopMatrix();
+		gpuPopMatrix();
 		
 		count++;
 		if (count == 8)
@@ -2285,7 +2286,7 @@ void GPU_state_init(void)
 	glDepthRange(0.0, 1.0);
 
 	glMatrixMode(GL_TEXTURE);
-	glLoadIdentity();
+	gpuLoadIdentity();
 	glMatrixMode(GL_MODELVIEW);
 
 	glFrontFace(GL_CCW);
diff --git a/source/blender/gpu/intern/gpu_framebu

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list