diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-04-04 21:33:23 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-04-05 16:02:31 +0300 |
commit | cbd78c81268f06e7b658ae042f3ab6a3816149b0 (patch) | |
tree | d5740e2643a7c42185ae94bc04575223c1af9045 /source/blender/gpu/intern/gpu_select_pick.c | |
parent | bbfa1a8639114d66ed0c4971a1996e08e520bd06 (diff) |
Immediate Mode: replacing glPushAttrib/glPopAttrib
Reference document: http://docs.gl/gl3/glPushAttrib
This patch only tackles the bits that are set by Blender with the
following exceptions:
1) Deprecated states (e.g., GL_STIPPLE) are not saved/restored
2) The exception being GL_ALPHA_TEST, which will be removed, but it may
affect drawing too much now. To be removed once we no longer set GL_ALPHA_TEST
elsewhere.
3) paint_cursor will be tackled separated, since it was abusing
glPush/PopAttrib in the first place.
4) Despite what the glPushAttrib page above may suggest, GL_DEPTH_WRITEMASK needs glGet, not glIsEnabled
5) BGE is still a problem since it relies on GL_ALL_ATTRIB_BITS which
would lead to a way more complete/lenghty solution. Since the BGE has
other (OpenGL deprecated) problems anyways, it can be handled on its own
time.
Finally, the original design for 2.8 was to implement a proper stack
system. However we need to move to core profile sooner than later. So
this is a pragmatic temporary (that may be permanent) solution.
Reviewers: merwin, campbellbarton
Differential Revision: https://developer.blender.org/D2600
Diffstat (limited to 'source/blender/gpu/intern/gpu_select_pick.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_select_pick.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c index 780ffd82671..da75925fe66 100644 --- a/source/blender/gpu/intern/gpu_select_pick.c +++ b/source/blender/gpu/intern/gpu_select_pick.c @@ -31,6 +31,8 @@ #include <stdlib.h> #include <float.h> +#include "GPU_immediate.h" +#include "GPU_draw.h" #include "GPU_select.h" #include "GPU_extensions.h" #include "GPU_glew.h" @@ -291,6 +293,8 @@ typedef struct GPUPickState { unsigned int *rect_id; } nearest; }; + + struct GPUStateValues attribs; } GPUPickState; @@ -316,8 +320,8 @@ void gpu_select_pick_begin( /* Restrict OpenGL operations for when we don't have cache */ if (ps->is_cached == false) { + gpuSaveState(&ps->attribs, GPU_DEPTH_BUFFER_BIT | GPU_VIEWPORT_BIT); - glPushAttrib(GL_DEPTH_BUFFER_BIT | GL_VIEWPORT_BIT); /* disable writing to the framebuffer */ glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); @@ -536,7 +540,7 @@ unsigned int gpu_select_pick_end(void) gpu_select_pick_load_id(ps->gl.prev_id); } - glPopAttrib(); + gpuRestoreState(&ps->attribs); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); } |