Get rid of glMatrixMode calls
With the explicit calls we don't need to worry about current state outside of the GPU module now. In fact. we don't need to worry about current matrix mode in core profile at all. Legacy OpenGL now has some code which ensures current matrix mode when using explicit calls to push/pop matrix.
This commit is contained in:
@@ -1377,9 +1377,7 @@ 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);
|
||||
gpuPushProjectionMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
gpuPushMatrix();
|
||||
gpuLoadIdentity();
|
||||
|
||||
@@ -1406,9 +1404,7 @@ void UI_block_draw(const bContext *C, uiBlock *block)
|
||||
}
|
||||
|
||||
/* restore matrix */
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
gpuPopProjectionMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
gpuPopMatrix();
|
||||
|
||||
if (multisample_enabled)
|
||||
|
||||
@@ -3175,9 +3175,7 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
|
||||
if (ibuf) {
|
||||
float x, y;
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
gpuPushProjectionMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
gpuPushMatrix();
|
||||
|
||||
/* somehow the offset has to be calculated inverse */
|
||||
@@ -3263,9 +3261,7 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
|
||||
}
|
||||
}
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
gpuPopProjectionMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
gpuPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
@@ -754,9 +754,7 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
gpuPushProjectionMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
gpuPushMatrix();
|
||||
ED_region_pixelspace(ar);
|
||||
|
||||
@@ -777,9 +775,7 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
|
||||
immDrawPixelsTex(&state, x1 - centx, y1 - centy, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, ibuf->rect,
|
||||
zoomx, zoomy, col);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
gpuPopProjectionMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
gpuPopMatrix();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
@@ -1822,10 +1818,8 @@ void ED_view3d_draw_offscreen(
|
||||
GPU_free_images_anim();
|
||||
}
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
gpuPushProjectionMatrix();
|
||||
gpuLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
gpuPushMatrix();
|
||||
gpuLoadIdentity();
|
||||
|
||||
@@ -1886,9 +1880,7 @@ void ED_view3d_draw_offscreen(
|
||||
ar->winy = bwiny;
|
||||
ar->winrct = brect;
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
gpuPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
gpuPopMatrix();
|
||||
|
||||
UI_Theme_Restore(&theme_state);
|
||||
@@ -2532,10 +2524,8 @@ void view3d_main_region_draw_legacy(const bContext *C, ARegion *ar)
|
||||
bool render_border = ED_view3d_calc_render_border(scene, v3d, ar, &border_rect);
|
||||
bool clip_border = (render_border && !BLI_rcti_compare(&ar->drawrct, &border_rect));
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
gpuPushProjectionMatrix();
|
||||
gpuLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
gpuLoadIdentityProjectionMatrix();
|
||||
gpuPushMatrix();
|
||||
gpuLoadIdentity();
|
||||
|
||||
@@ -2564,9 +2554,7 @@ void view3d_main_region_draw_legacy(const bContext *C, ARegion *ar)
|
||||
|
||||
view3d_main_region_draw_info(C, scene, ar, v3d, grid_unit, render_border);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
gpuPopProjectionMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
gpuPopMatrix();
|
||||
|
||||
v3d->flag |= V3D_INVALID_BACKBUF;
|
||||
|
||||
@@ -94,6 +94,7 @@ void gpuPopProjectionMatrix(void);
|
||||
|
||||
/* 3D Projection Matrix */
|
||||
|
||||
void gpuLoadIdentityProjectionMatrix(void);
|
||||
void gpuLoadProjectionMatrix(const float m[4][4]);
|
||||
|
||||
void gpuOrtho(float left, float right, float bottom, float top, float near, float far);
|
||||
|
||||
@@ -119,7 +119,18 @@ void gpuPushMatrix(void)
|
||||
{
|
||||
#if SUPPORT_LEGACY_MATRIX
|
||||
{
|
||||
GLenum mode;
|
||||
glGetIntegerv(GL_MATRIX_MODE, (GLint*)&mode);
|
||||
if (mode != GL_MODELVIEW) {
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
if (mode != GL_MODELVIEW) {
|
||||
glMatrixMode(mode); /* restore */
|
||||
}
|
||||
|
||||
state.dirty = true;
|
||||
return;
|
||||
}
|
||||
@@ -134,7 +145,18 @@ void gpuPopMatrix(void)
|
||||
{
|
||||
#if SUPPORT_LEGACY_MATRIX
|
||||
{
|
||||
GLenum mode;
|
||||
glGetIntegerv(GL_MATRIX_MODE, (GLint*)&mode);
|
||||
if (mode != GL_MODELVIEW) {
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
if (mode != GL_MODELVIEW) {
|
||||
glMatrixMode(mode); /* restore */
|
||||
}
|
||||
|
||||
state.dirty = true;
|
||||
return;
|
||||
}
|
||||
@@ -149,7 +171,18 @@ void gpuPushProjectionMatrix(void)
|
||||
{
|
||||
#if SUPPORT_LEGACY_MATRIX
|
||||
{
|
||||
GLenum mode;
|
||||
glGetIntegerv(GL_MATRIX_MODE, (GLint*)&mode);
|
||||
if (mode != GL_PROJECTION) {
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
if (mode != GL_PROJECTION) {
|
||||
glMatrixMode(mode); /* restore */
|
||||
}
|
||||
|
||||
state.dirty = true;
|
||||
return;
|
||||
}
|
||||
@@ -164,7 +197,18 @@ void gpuPopProjectionMatrix(void)
|
||||
{
|
||||
#if SUPPORT_LEGACY_MATRIX
|
||||
{
|
||||
GLenum mode;
|
||||
glGetIntegerv(GL_MATRIX_MODE, (GLint*)&mode);
|
||||
if (mode != GL_PROJECTION) {
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
if (mode != GL_PROJECTION) {
|
||||
glMatrixMode(mode); /* restore */
|
||||
}
|
||||
|
||||
state.dirty = true;
|
||||
return;
|
||||
}
|
||||
@@ -190,6 +234,32 @@ void gpuLoadMatrix(const float m[4][4])
|
||||
state.dirty = true;
|
||||
}
|
||||
|
||||
void gpuLoadIdentityProjectionMatrix(void)
|
||||
{
|
||||
#if SUPPORT_LEGACY_MATRIX
|
||||
{
|
||||
GLenum mode;
|
||||
glGetIntegerv(GL_MATRIX_MODE, (GLint*)&mode);
|
||||
if (mode != GL_PROJECTION) {
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
}
|
||||
|
||||
glLoadIdentity();
|
||||
|
||||
if (mode != GL_PROJECTION_MATRIX) {
|
||||
glMatrixMode(mode); /* restore */
|
||||
}
|
||||
|
||||
state.dirty = true;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
unit_m4(Projection);
|
||||
CHECKMAT(Projection3D);
|
||||
state.dirty = true;
|
||||
}
|
||||
|
||||
void gpuLoadProjectionMatrix(const float m[4][4])
|
||||
{
|
||||
#if SUPPORT_LEGACY_MATRIX
|
||||
|
||||
@@ -360,10 +360,8 @@ 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); /* TODO: convert this nasty code */
|
||||
gpuPushProjectionMatrix();
|
||||
gpuLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
gpuLoadIdentityProjectionMatrix();
|
||||
gpuPushMatrix();
|
||||
gpuLoadIdentity();
|
||||
|
||||
@@ -380,9 +378,7 @@ static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf
|
||||
immUnbindProgram();
|
||||
|
||||
gpuPopMatrix();
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
gpuPopProjectionMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
GHOST_SwapWindowBuffers(g_WS.ghost_window);
|
||||
|
||||
Reference in New Issue
Block a user