Avoid clearing the depth buffer when using full screen quads for

gradients
This commit is contained in:
Antony Riakiotakis
2013-03-04 16:34:37 +00:00
parent f5a28a288b
commit 9de5c35ce0

View File

@@ -2996,7 +2996,7 @@ static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar)
#define VIEWGRAD_RES_Y 16
GLubyte grid_col[VIEWGRAD_RES_X][VIEWGRAD_RES_Y][4];
static float grid_pos[VIEWGRAD_RES_X][VIEWGRAD_RES_Y][2];
static float grid_pos[VIEWGRAD_RES_X][VIEWGRAD_RES_Y][3];
static GLushort indices[VIEWGRAD_RES_X - 1][VIEWGRAD_RES_X - 1][4];
static char buf_calculated = FALSE;
@@ -3005,8 +3005,6 @@ static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar)
IMB_colormanagement_pixel_to_display_space_v3(col_zen, &scene->world->zenr, &scene->view_settings,
&scene->display_settings);
glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
@@ -3026,6 +3024,7 @@ static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar)
/* -1..1 range */
grid_pos[x][y][0] = (xf - 0.5f) * 2.0f;
grid_pos[x][y][1] = (yf - 0.5f) * 2.0f;
grid_pos[x][y][2] = 1.0;
}
}
@@ -3079,15 +3078,22 @@ static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar)
}
}
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_ALWAYS);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, grid_pos);
glVertexPointer(3, GL_FLOAT, 0, grid_pos);
glColorPointer(4, GL_UNSIGNED_BYTE, 0, grid_col);
glDrawElements(GL_QUADS, (VIEWGRAD_RES_X - 1) * (VIEWGRAD_RES_Y - 1) * 4, GL_UNSIGNED_SHORT, indices);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDepthFunc(GL_LEQUAL);
glDisable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
@@ -3109,9 +3115,6 @@ static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar)
}
else {
if (UI_GetThemeValue(TH_SHOW_BACK_GRAD)) {
/* only clear depth buffer here */
glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
@@ -3119,17 +3122,22 @@ static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar)
glPushMatrix();
glLoadIdentity();
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_ALWAYS);
glShadeModel(GL_SMOOTH);
glBegin(GL_QUADS);
UI_ThemeColor(TH_LOW_GRAD);
glVertex2f(-1.0, -1.0);
glVertex2f(1.0, -1.0);
glVertex3f(-1.0, -1.0, 1.0);
glVertex3f(1.0, -1.0, 1.0);
UI_ThemeColor(TH_HIGH_GRAD);
glVertex2f(1.0, 1.0);
glVertex2f(-1.0, 1.0);
glVertex3f(1.0, 1.0, 1.0);
glVertex3f(-1.0, 1.0, 1.0);
glEnd();
glShadeModel(GL_FLAT);
glDepthFunc(GL_LEQUAL);
glDisable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glPopMatrix();