Cleanup: GPU: Encapsulate glViewport calls

This commit is contained in:
2020-07-17 19:03:30 +02:00
parent 35f1b3e43b
commit a6bd7777c2
9 changed files with 26 additions and 20 deletions

View File

@@ -209,7 +209,7 @@ static void wm_gesture_draw_line(wmGesture *gt)
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
GPU_viewport_size_get_f(viewport_size);
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
immUniform1i("colors_len", 2); /* "advanced" mode */
@@ -252,7 +252,7 @@ static void wm_gesture_draw_rect(wmGesture *gt)
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
GPU_viewport_size_get_f(viewport_size);
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
immUniform1i("colors_len", 2); /* "advanced" mode */
@@ -291,7 +291,7 @@ static void wm_gesture_draw_circle(wmGesture *gt)
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
GPU_viewport_size_get_f(viewport_size);
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
immUniform1i("colors_len", 2); /* "advanced" mode */
@@ -408,7 +408,7 @@ static void wm_gesture_draw_lasso(wmGesture *gt, bool filled)
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
GPU_viewport_size_get_f(viewport_size);
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
immUniform1i("colors_len", 2); /* "advanced" mode */
@@ -442,7 +442,7 @@ static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt)
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
GPU_viewport_size_get_f(viewport_size);
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
immUniform1i("colors_len", 2); /* "advanced" mode */

View File

@@ -1060,7 +1060,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
/* zoom always show entire image */
ps->zoom = MIN2(zoomx, zoomy);
glViewport(0, 0, ps->win_x, ps->win_y);
GPU_viewport(0, 0, ps->win_x, ps->win_y);
glScissor(0, 0, ps->win_x, ps->win_y);
playanim_gl_matrix();
@@ -1322,7 +1322,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
int win_x, win_y;
playanim_window_get_size(&win_x, &win_y);
glViewport(0, 0, win_x, win_y);
GPU_viewport(0, 0, win_x, win_y);
glScissor(0, 0, win_x, win_y);
playanim_gl_matrix();

View File

@@ -40,7 +40,7 @@ void wmViewport(const rcti *winrct)
int width = BLI_rcti_size_x(winrct) + 1;
int height = BLI_rcti_size_y(winrct) + 1;
glViewport(winrct->xmin, winrct->ymin, width, height);
GPU_viewport(winrct->xmin, winrct->ymin, width, height);
glScissor(winrct->xmin, winrct->ymin, width, height);
wmOrtho2_pixelspace(width, height);
@@ -79,7 +79,7 @@ void wmPartialViewport(rcti *drawrct, const rcti *winrct, const rcti *partialrct
scissor_height += 1;
}
glViewport(0, 0, width, height);
GPU_viewport(0, 0, width, height);
glScissor(x, y, scissor_width, scissor_height);
wmOrtho2_pixelspace(width, height);
@@ -91,7 +91,7 @@ void wmWindowViewport(wmWindow *win)
int width = WM_window_pixels_x(win);
int height = WM_window_pixels_y(win);
glViewport(0, 0, width, height);
GPU_viewport(0, 0, width, height);
glScissor(0, 0, width, height);
wmOrtho2_pixelspace(width, height);