OpenGL: remove several glMatrixMode calls
A few of these were redundant, others could be converted to new matrix API. Part of T49450
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user