Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2020-07-17 20:03:30 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-07-18 04:43:52 +0300
commita6bd7777c20aa229ae9c4cdd537e94cf8a9c7edf (patch)
tree839f559613038d8ec17e18b7bc85b1a231bf01a4 /source/blender/gpu
parent35f1b3e43b37006486b94675466cf4260087e269 (diff)
Cleanup: GPU: Encapsulate glViewport calls
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/GPU_state.h1
-rw-r--r--source/blender/gpu/intern/gpu_select_pick.c4
-rw-r--r--source/blender/gpu/intern/gpu_select_sample_query.c4
-rw-r--r--source/blender/gpu/intern/gpu_state.c5
4 files changed, 10 insertions, 4 deletions
diff --git a/source/blender/gpu/GPU_state.h b/source/blender/gpu/GPU_state.h
index 36a82e31521..4aa88d2e037 100644
--- a/source/blender/gpu/GPU_state.h
+++ b/source/blender/gpu/GPU_state.h
@@ -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);
diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c
index 3e5fc1ab19e..c6d8545527c 100644
--- a/source/blender/gpu/intern/gpu_select_pick.c
+++ b/source/blender/gpu/intern/gpu_select_pick.c
@@ -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. */
diff --git a/source/blender/gpu/intern/gpu_select_sample_query.c b/source/blender/gpu/intern/gpu_select_sample_query.c
index b20b6cac36b..70ad2f6759e 100644
--- a/source/blender/gpu/intern/gpu_select_sample_query.c
+++ b/source/blender/gpu/intern/gpu_select_sample_query.c
@@ -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 */
diff --git a/source/blender/gpu/intern/gpu_state.c b/source/blender/gpu/intern/gpu_state.c
index 8dc246904df..1e79212fc4e 100644
--- a/source/blender/gpu/intern/gpu_state.c
+++ b/source/blender/gpu/intern/gpu_state.c
@@ -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);