Cleanup: GPU: Encapsulate glViewport calls
This commit is contained in:
@@ -63,6 +63,7 @@ void GPU_program_point_size(bool enable);
|
||||
void GPU_scissor(int x, int y, int width, int height);
|
||||
void GPU_scissor_get_f(float coords[4]);
|
||||
void GPU_scissor_get_i(int coords[4]);
|
||||
void GPU_viewport(int x, int y, int width, int height);
|
||||
void GPU_viewport_size_get_f(float coords[4]);
|
||||
void GPU_viewport_size_get_i(int coords[4]);
|
||||
void GPU_color_mask(bool r, bool g, bool b, bool a);
|
||||
|
||||
@@ -320,7 +320,7 @@ void gpu_select_pick_begin(uint (*buffer)[4], uint bufsize, const rcti *input, c
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
|
||||
float viewport[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport);
|
||||
GPU_viewport_size_get_f(viewport);
|
||||
|
||||
ps->src.clip_rect = *input;
|
||||
ps->src.rect_len = rect_len;
|
||||
@@ -330,7 +330,7 @@ void gpu_select_pick_begin(uint (*buffer)[4], uint bufsize, const rcti *input, c
|
||||
ps->gl.clip_readpixels[2] = BLI_rcti_size_x(&ps->src.clip_rect);
|
||||
ps->gl.clip_readpixels[3] = BLI_rcti_size_y(&ps->src.clip_rect);
|
||||
|
||||
glViewport(UNPACK4(ps->gl.clip_readpixels));
|
||||
GPU_viewport(UNPACK4(ps->gl.clip_readpixels));
|
||||
|
||||
/* It's possible we don't want to clear depth buffer,
|
||||
* so existing elements are masked by current z-buffer. */
|
||||
|
||||
@@ -94,8 +94,8 @@ void gpu_select_query_begin(
|
||||
* We need to get the region of the viewport so that our geometry doesn't
|
||||
* get rejected before the depth test. Should probably cull rect against
|
||||
* the viewport but this is a rare case I think */
|
||||
glGetFloatv(GL_VIEWPORT, viewport);
|
||||
glViewport(viewport[0], viewport[1], BLI_rcti_size_x(input), BLI_rcti_size_y(input));
|
||||
GPU_viewport_size_get_f(viewport);
|
||||
GPU_viewport(viewport[0], viewport[1], BLI_rcti_size_x(input), BLI_rcti_size_y(input));
|
||||
|
||||
/* occlusion queries operates on fragments that pass tests and since we are interested on all
|
||||
* objects in the view frustum independently of their order, we need to disable the depth test */
|
||||
|
||||
@@ -151,6 +151,11 @@ void GPU_scissor(int x, int y, int width, int height)
|
||||
glScissor(x, y, width, height);
|
||||
}
|
||||
|
||||
void GPU_viewport(int x, int y, int width, int height)
|
||||
{
|
||||
glViewport(x, y, width, height);
|
||||
}
|
||||
|
||||
void GPU_scissor_get_f(float coords[4])
|
||||
{
|
||||
glGetFloatv(GL_SCISSOR_BOX, coords);
|
||||
|
||||
Reference in New Issue
Block a user