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

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


Commit: 3bd831d1d61634e533227bccc04a46574289b774
Author: Mike Erwin
Date:   Tue Mar 21 16:08:14 2017 -0400
Branches: blender2.8
https://developer.blender.org/rB3bd831d1d61634e533227bccc04a46574289b774

OpenGL: convert to new matrix API (part 4)

Part of T49450, fixes a Push/Pop mismatch from part yesterday's 3.

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

M	source/blender/editors/animation/anim_draw.c
M	source/blender/editors/animation/anim_markers.c
M	source/blender/editors/interface/interface.c
M	source/blender/editors/mask/mask_draw.c
M	source/blender/editors/render/render_opengl.c
M	source/blender/editors/screen/glutil.c
M	source/blender/editors/screen/screen_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_image/image_draw.c
M	source/blender/editors/space_view3d/drawarmature.c
M	source/blender/editors/transform/transform_constraints.c
M	source/blender/gpu/intern/gpu_draw.c

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

diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index 1d71ba8dc3..5d357e2f93 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -58,13 +58,12 @@
 
 #include "RNA_access.h"
 
-#include "BIF_gl.h"
-
 #include "UI_interface.h"
 #include "UI_resources.h"
 #include "UI_view2d.h"
 
 #include "GPU_immediate.h"
+#include "GPU_matrix.h"
 
 /* *************************************************** */
 /* CURRENT FRAME DRAWING */
@@ -81,8 +80,9 @@ static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const
 	int slen;
 	
 	/* because the frame number text is subject to the same scaling as the contents of the view */
+	gpuPushMatrix();
 	UI_view2d_scale_get(v2d, &xscale, &yscale);
-	glScalef(1.0f / xscale, 1.0f, 1.0f);
+	gpuScale2f(1.0f / xscale, 1.0f);
 	
 	/* get timecode string 
 	 *	- padding on str-buf passed so that it doesn't sit on the frame indicator
@@ -115,7 +115,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, col);
 
 	/* restore view transform */
-	glScalef(xscale, 1.0, 1.0);
+	gpuPopMatrix();
 }
 
 /* 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 cc5957003b..9d7d1535eb 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -56,10 +56,10 @@
 #include "WM_api.h"
 #include "WM_types.h"
 
-#include "BIF_gl.h"
 #include "BIF_glutil.h"
 
 #include "GPU_immediate.h"
+#include "GPU_matrix.h"
 
 #include "UI_interface.h"
 #include "UI_interface_icons.h"
@@ -464,7 +464,8 @@ 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);
-	glScalef(1.0f / xscale, 1.0f, 1.0f);
+	gpuPushMatrix();
+	gpuScale2f(1.0f / xscale, 1.0f);
 
 	/* x-bounds with offset for text (adjust for long string, avoid checking string width) */
 	font_width_max = (10 * UI_DPI_FAC) / xscale;
@@ -487,7 +488,7 @@ void ED_markers_draw(const bContext *C, int flag)
 		}
 	}
 
-	glScalef(xscale, 1.0f, 1.0f);
+	gpuPopMatrix();
 }
 
 /* ************************ Marker Wrappers API ********************* */
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 24601cc218..cf19565b17 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -56,7 +56,7 @@
 #include "BKE_screen.h"
 #include "BKE_idprop.h"
 
-#include "BIF_gl.h"
+#include "GPU_matrix.h"
 
 #include "BLF_api.h"
 #include "BLT_translation.h"
@@ -1378,10 +1378,10 @@ void UI_block_draw(const bContext *C, uiBlock *block)
 	
 	/* pixel space for AA widgets */
 	glMatrixMode(GL_PROJECTION);
-	glPushMatrix();
+	gpuPushMatrix();
 	glMatrixMode(GL_MODELVIEW);
-	glPushMatrix();
-	glLoadIdentity();
+	gpuPushMatrix();
+	gpuLoadIdentity();
 
 	wmOrtho2_region_pixelspace(ar);
 	
@@ -1407,9 +1407,9 @@ void UI_block_draw(const bContext *C, uiBlock *block)
 	
 	/* restore matrix */
 	glMatrixMode(GL_PROJECTION);
-	glPopMatrix();
+	gpuPopMatrix();
 	glMatrixMode(GL_MODELVIEW);
-	glPopMatrix();
+	gpuPopMatrix();
 
 	if (multisample_enabled)
 		glEnable(GL_MULTISAMPLE);
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index 7a30cefd9f..eb3721a7ed 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -55,6 +55,7 @@
 #include "GPU_immediate.h"
 #include "GPU_draw.h"
 #include "GPU_shader.h"
+#include "GPU_matrix.h"
 
 #include "UI_resources.h"
 #include "UI_view2d.h"
@@ -762,17 +763,17 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar,
 			glBlendFunc(GL_DST_COLOR, GL_ZERO);
 		}
 
-		glPushMatrix();
-		glTranslatef(x, y, 0);
-		glScalef(zoomx, zoomy, 0);
+		gpuPushMatrix();
+		gpuTranslate2f(x, y);
+		gpuScale2f(zoomx, zoomy);
 		if (stabmat) {
-			glMultMatrixf((const float *) stabmat);
+			gpuMultMatrix3D(stabmat); /* XXX make this a 2D matrix */
 		}
 		GPUShader *shader = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
 		GPU_shader_uniform_vector(shader, GPU_shader_get_uniform(shader, "shuffle"), 4, 1, red);
 		immDrawPixelsTex(0.0f, 0.0f, width, height, GL_RED, GL_FLOAT, GL_NEAREST, buffer, 1.0f, 1.0f, NULL);
 
-		glPopMatrix();
+		gpuPopMatrix();
 
 		if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) {
 			glDisable(GL_BLEND);
@@ -782,14 +783,14 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar,
 	}
 
 	/* apply transformation so mask editing tools will assume drawing from the origin in normalized space */
-	glPushMatrix();
+	gpuPushMatrix();
 
 	if (stabmat) {
-		glMultMatrixf((const float *) stabmat);
+		gpuMultMatrix3D(stabmat); /* XXX make this a 2D matrix */
 	}
 
-	glTranslatef(x + xofs, y + yofs, 0);
-	glScalef(maxdim * zoomx, maxdim * zoomy, 0);
+	gpuTranslate2f(x + xofs, y + yofs);
+	gpuScale2f(maxdim * zoomx, maxdim * zoomy);
 
 	if (do_draw_cb) {
 		ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
@@ -802,7 +803,7 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar,
 		ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
 	}
 
-	glPopMatrix();
+	gpuPopMatrix();
 }
 
 void ED_mask_draw_frames(Mask *mask, ARegion *ar, const int cfra, const int sfra, const int efra)
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 1d870b8902..91bf0eeaa3 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -71,9 +71,9 @@
 #include "RNA_access.h"
 #include "RNA_define.h"
 
-#include "GPU_glew.h"
 #include "GPU_compositing.h"
 #include "GPU_framebuffer.h"
+#include "GPU_matrix.h"
 
 #include "render_intern.h"
 
@@ -335,7 +335,7 @@ static void screen_opengl_render_doit(OGLRender *oglrender, RenderResult *rr)
 			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
 			wmOrtho2(0, sizex, 0, sizey);
-			glTranslatef(sizex / 2, sizey / 2, 0.0f);
+			gpuTranslate2f(sizex / 2, sizey / 2);
 
 			G.f |= G_RENDER_OGL;
 			ED_gpencil_draw_ex(scene, gpd, sizex, sizey, scene->r.cfra, SPACE_SEQ);
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index f1ad04c098..fd0e1febdd 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -50,6 +50,7 @@
 
 #include "GPU_basic_shader.h"
 #include "GPU_immediate.h"
+#include "GPU_matrix.h"
 
 #include "UI_interface.h"
 
@@ -568,12 +569,12 @@ void glaDefine2DArea(rcti *screen_rect)
 	 */
 
 	glMatrixMode(GL_PROJECTION);
-	glLoadIdentity();
+	gpuLoadIdentity();
 	glOrtho(0.0, sc_w, 0.0, sc_h, -1, 1);
-	glTranslatef(GLA_PIXEL_OFS, GLA_PIXEL_OFS, 0.0);
+	gpuTranslate2f(GLA_PIXEL_OFS, GLA_PIXEL_OFS);
 
 	glMatrixMode(GL_MODELVIEW);
-	glLoadIdentity();
+	gpuLoadIdentity();
 }
 
 /* TODO(merwin): put the following 2D code to use, or build new 2D code inspired & informd by it */
@@ -684,9 +685,9 @@ 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]);
 	glMatrixMode(GL_PROJECTION);
-	glLoadMatrixf(di->orig_projmat);
+	gpuLoadMatrix3D(di->orig_projmat);
 	glMatrixMode(GL_MODELVIEW);
-	glLoadMatrixf(di->orig_viewmat);
+	gpuLoadMatrix3D(di->orig_viewmat);
 
 	MEM_freeN(di);
 }
@@ -743,14 +744,14 @@ void bglPolygonOffset(float viewdist, float dist)
 		winmat[14] -= offs;
 		offset += offs;
 		
-		glLoadMatrixf(winmat);
+		gpuLoadMatrix3D(winmat);
 		glMatrixMode(GL_MODELVIEW);
 	}
 	else {
 		glMatrixMode(GL_PROJECTION);
 		winmat[14] += offset;
 		offset = 0.0;
-		glLoadMatrixf(winmat);
+		gpuLoadMatrix3D(winmat);
 		glMatrixMode(GL_MODELVIEW);
 	}
 }
diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c
index 7d85f9bb1c..22c6f070ac 100644
--- a/source/blender/editors/screen/screen_draw.c
+++ b/source/blender/editors/screen/screen_draw.c
@@ -26,6 +26,7 @@
 
 #include "GPU_framebuffer.h"
 #include "GPU_immediate.h"
+#include "GPU_matrix.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -463,7 +464,7 @@ static void screen_preview_draw(const bScreen *screen, int size_x, int size_y)
 
 	wmOrtho2(0.0f, size_x, 0.0f, size_y);
 	/* center */
-	glTranslatef(size_x * (1.0f - asp[0]) * 0.5f, size_y * (1.0f - asp[1]) * 0.5f, 0.0f);
+	gpuTranslate2f(size_x * (1.0f - asp[0]) * 0.5f, size_y * (1.0f - asp[1]) * 0.5f);
 
 	screen_preview_scale_get(screen, size_x, size_y, asp, scale);
 	screen_preview_draw_areas(screen, scale, col, 1.5f);
diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c
index 560cf1f905..1cddacc0fc 100644
--- a/source/blender/editors/space_clip/clip_utils.c
+++ b/source/blender/editors/space_clip/clip_utils.c
@@ -44,6 +44,7 @@
 #include "BKE_depsgraph.h"
 
 #include "GPU_immediate.h"
+#include "GPU_matrix.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -263,13 +264,13 @@ void clip_draw_cfra(SpaceClip *sc, ARegion *ar, Scene *scene)
 	/* because the frame number text is subject to the same scaling as the contents of the view */
 	float xscale, yscale;
 	UI_view2d_scale_get(v2d, &xscale, &yscale);
-	glPushMatrix();
-	glScalef(1.0f / xscale, 1.0f, 1.0f);
+	gpuPushMatrix();
+	gpuScale2f(1.0f / xscale, 1.0f);
 
 	ED_region_cache_draw_curfra_label(sc->user.framenr, (float)sc->user.framenr * xscale, 18);
 
 	/* restore view transform */
-	glPopMatrix();
+	gpuPopMatrix();
 }
 
 void clip_draw_sfra_efra(View2D *v2d, Scene *scene)
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index 05e69968e3..9f35fff5e7 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -60,7 +60,7 @@
 
 #include "IMB_imbuf.h"
 
-#include "BIF_gl.h"
+#include "GPU_matrix

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list