Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorMike Erwin <significant.bit@gmail.com>2017-03-24 04:36:34 +0300
committerMike Erwin <significant.bit@gmail.com>2017-03-27 04:23:54 +0300
commit67ffad8cd2b44d7685ec5aec2a76e1cb13d9f7a1 (patch)
tree3b62b443ab3602476c9f1fe1f42549d4d85f2b41 /source
parent59c562337291217c2fbd48adc8b3862c24771d09 (diff)
OpenGL: remove several glMatrixMode calls
A few of these were redundant, others could be converted to new matrix API. Part of T49450
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/interface/interface.c8
-rw-r--r--source/blender/editors/screen/glutil.c5
-rw-r--r--source/blender/editors/space_node/drawnode.c6
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c8
-rw-r--r--source/blender/editors/space_view3d/drawobject.c12
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c38
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c7
7 files changed, 29 insertions, 55 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index cf19565b170..011786f6cdc 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1377,9 +1377,6 @@ void UI_block_draw(const bContext *C, uiBlock *block)
ui_but_to_pixelrect(&rect, ar, block, NULL);
/* pixel space for AA widgets */
- glMatrixMode(GL_PROJECTION);
- gpuPushMatrix();
- glMatrixMode(GL_MODELVIEW);
gpuPushMatrix();
gpuLoadIdentity();
@@ -1405,10 +1402,7 @@ void UI_block_draw(const bContext *C, uiBlock *block)
}
}
- /* restore matrix */
- glMatrixMode(GL_PROJECTION);
- gpuPopMatrix();
- glMatrixMode(GL_MODELVIEW);
+ /* restore model-view matrix */
gpuPopMatrix();
if (multisample_enabled)
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index 10db4edd85b..c66268beb9f 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -559,6 +559,10 @@ 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);
@@ -566,6 +570,7 @@ void glaDefine2DArea(rcti *screen_rect)
glMatrixMode(GL_MODELVIEW);
gpuLoadIdentity();
+#endif
}
/* TODO(merwin): put the following 2D code to use, or build new 2D code inspired & informd by it */
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 7b560462a9d..009d33b4ddb 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -3185,9 +3185,6 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
if (ibuf) {
float x, y;
- glMatrixMode(GL_PROJECTION);
- gpuPushMatrix();
- glMatrixMode(GL_MODELVIEW);
gpuPushMatrix();
/* somehow the offset has to be calculated inverse */
@@ -3273,9 +3270,6 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
}
}
- glMatrixMode(GL_PROJECTION);
- gpuPopMatrix();
- glMatrixMode(GL_MODELVIEW);
gpuPopMatrix();
}
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 36aa3358b18..1fea1a98e94 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -1287,10 +1287,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
}
if (draw_backdrop) {
- glMatrixMode(GL_PROJECTION);
- gpuPushMatrix();
- gpuLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
+ /* XXX: need to load identity projection too? */
gpuPushMatrix();
gpuLoadIdentity();
}
@@ -1422,9 +1419,6 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
if (draw_backdrop) {
gpuPopMatrix();
- glMatrixMode(GL_PROJECTION);
- gpuPopMatrix();
- glMatrixMode(GL_MODELVIEW);
return;
}
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index e41cc4aa2e7..be0a612a8d8 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -934,11 +934,11 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, bool depth_write, flo
ED_view3d_clipping_disable();
}
- glMatrixMode(GL_PROJECTION);
- gpuPushMatrix();
- glMatrixMode(GL_MODELVIEW);
- gpuPushMatrix();
+ float original_proj[4][4];
+ gpuGetProjectionMatrix3D(original_proj);
wmOrtho2_region_pixelspace(ar);
+
+ gpuPushMatrix();
gpuLoadIdentity();
if (depth_write) {
@@ -973,10 +973,8 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, bool depth_write, flo
glDepthMask(GL_TRUE);
}
- glMatrixMode(GL_PROJECTION);
- gpuPopMatrix();
- glMatrixMode(GL_MODELVIEW);
gpuPopMatrix();
+ gpuLoadProjectionMatrix3D(original_proj); /* TODO: make this more 2D friendly */
if (rv3d->rflag & RV3D_CLIPPING) {
ED_view3d_clipping_enable();
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 808a5f34299..808933b5d80 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -768,11 +768,10 @@ static bool view3d_draw_render_draw(const bContext *C, Scene *scene,
rv3d->render_engine = engine;
}
- /* background draw */
- glMatrixMode(GL_PROJECTION);
- gpuPushMatrix();
- glMatrixMode(GL_MODELVIEW);
+ /* rendered draw */
gpuPushMatrix();
+ float original_proj[4][4];
+ gpuGetProjectionMatrix3D(original_proj);
ED_region_pixelspace(ar);
if (clip_border) {
@@ -787,8 +786,8 @@ static bool view3d_draw_render_draw(const bContext *C, Scene *scene,
}
}
- glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
/* don't change depth buffer */
+ glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT); /* is this necessary? -- merwin */
/* render result draw */
@@ -800,9 +799,7 @@ static bool view3d_draw_render_draw(const bContext *C, Scene *scene,
glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
}
- glMatrixMode(GL_PROJECTION);
- gpuPopMatrix();
- glMatrixMode(GL_MODELVIEW);
+ gpuLoadProjectionMatrix3D(original_proj);
gpuPopMatrix();
return true;
@@ -1762,10 +1759,7 @@ static void view3d_draw_non_mesh(
Scene *scene, SceneLayer *sl, Object *ob, Base *base, View3D *v3d,
RegionView3D *rv3d, const bool is_boundingbox, const unsigned char color[4])
{
- glMatrixMode(GL_PROJECTION);
- gpuPushMatrix();
- glMatrixMode(GL_MODELVIEW);
- gpuPushMatrix();
+ gpuPushMatrix(); /* necessary? --merwin */
/* multiply view with object matrix.
* local viewmat and persmat, to calculate projections */
@@ -1808,12 +1802,9 @@ RegionView3D *rv3d, const bool is_boundingbox, const unsigned char color[4])
draw_rigidbody_shape(ob, color);
}
- ED_view3d_clear_mats_rv3d(rv3d);
+ ED_view3d_clear_mats_rv3d(rv3d); /* no effect in release builds */
- glMatrixMode(GL_PROJECTION);
- gpuPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- gpuPopMatrix();
+ gpuPopMatrix(); /* see above */
}
/* ******************** info ***************** */
@@ -2128,11 +2119,12 @@ static void view3d_draw_solid_plates(const bContext *C, ARegion *ar, DrawData *d
view3d_draw_post_draw(C);
}
- /* offline plates*/
+ /* offline plates */
if (draw_data->is_render) {
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
+ /* TODO: move this outside of solid plates, after solid & before other 3D elements */
view3d_draw_render_draw(C, scene, ar, v3d, draw_data->clip_border, &draw_data->border_rect);
}
@@ -2294,10 +2286,10 @@ static void view3d_draw_view(const bContext *C, ARegion *ar, DrawData *draw_data
glClear(GL_DEPTH_BUFFER_BIT);
// glDisable(GL_DEPTH_TEST); /* should be set by default */
- glMatrixMode(GL_PROJECTION);
- gpuLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
- gpuLoadIdentity();
+ glMatrixMode(GL_PROJECTION); //
+ gpuLoadIdentity(); // TODO: replace these lines with gpuMatrixBegin3D
+ glMatrixMode(GL_MODELVIEW); //
+ gpuLoadIdentity(); //
view3d_draw_background(C); /* clears/overwrites entire color buffer */
@@ -2308,7 +2300,7 @@ static void view3d_draw_view(const bContext *C, ARegion *ar, DrawData *draw_data
view3d_draw_prerender_buffers(C, ar, draw_data); /* depth pre-pass */
// glDepthFunc(GL_EQUAL); /* TODO: do this after separating surfaces from wires */
-// glDepthMask(GL_FALSE); /* TODO: do this after separating surfaces from wires */
+// glDepthMask(GL_FALSE); /* same TODO as above */
view3d_draw_solid_plates(C, ar, draw_data);
// glDepthFunc(GL_LEQUAL); /* same TODO as above */
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index 926220f8c6c..46c7599ec56 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -192,10 +192,7 @@ static void playanim_window_get_size(int *r_width, int *r_height)
static void playanim_gl_matrix(void)
{
/* unified matrix, note it affects offset for drawing */
- glMatrixMode(GL_PROJECTION);
- gpuLoadIdentity();
- glOrtho(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f); /* XXX revisit this when 2D matrix API is complete */
- glMatrixMode(GL_MODELVIEW);
+ gpuOrtho2D(0.0f, 1.0f, 0.0f, 1.0f);
}
/* implementation */
@@ -356,7 +353,7 @@ static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf
float fac = ps->picture->frame / (double)(((PlayAnimPict *)picsbase.last)->frame - ((PlayAnimPict *)picsbase.first)->frame);
fac = 2.0f * fac - 1.0f;
- glMatrixMode(GL_PROJECTION);
+ glMatrixMode(GL_PROJECTION); /* TODO: convert this nasty code */
gpuPushMatrix();
gpuLoadIdentity();
glMatrixMode(GL_MODELVIEW);