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_framebuffer.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_framebuffer.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_framebuffer.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c index ce35c43bcec..c6a98d01c02 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.c +++ b/source/blender/gpu/intern/gpu_framebuffer.c @@ -33,6 +33,7 @@ #include "BKE_global.h" #include "GPU_batch.h" +#include "GPU_draw.h" #include "GPU_framebuffer.h" #include "GPU_matrix.h" #include "GPU_shader.h" @@ -50,6 +51,7 @@ struct GPUFrameBuffer { GLuint object; GPUTexture *colortex[GPU_FB_MAX_SLOTS]; GPUTexture *depthtex; + struct GPUStateValues attribs; }; static void GPU_print_framebuffer_error(GLenum status, char err_out[256]) @@ -198,7 +200,7 @@ void GPU_texture_bind_as_framebuffer(GPUTexture *tex) } /* push attributes */ - glPushAttrib(GL_ENABLE_BIT | GL_VIEWPORT_BIT); + gpuSaveState(&fb->attribs, GPU_ENABLE_BIT | GPU_VIEWPORT_BIT); glDisable(GL_SCISSOR_TEST); /* bind framebuffer */ @@ -241,7 +243,7 @@ void GPU_framebuffer_slots_bind(GPUFrameBuffer *fb, int slot) } /* push attributes */ - glPushAttrib(GL_ENABLE_BIT | GL_VIEWPORT_BIT); + gpuSaveState(&fb->attribs, GPU_ENABLE_BIT | GPU_VIEWPORT_BIT); glDisable(GL_SCISSOR_TEST); /* bind framebuffer */ @@ -294,10 +296,10 @@ void GPU_framebuffer_bind(GPUFrameBuffer *fb) } -void GPU_framebuffer_texture_unbind(GPUFrameBuffer *UNUSED(fb), GPUTexture *UNUSED(tex)) +void GPU_framebuffer_texture_unbind(GPUFrameBuffer *fb, GPUTexture *UNUSED(tex)) { /* restore attributes */ - glPopAttrib(); + gpuRestoreState(&fb->attribs); } void GPU_framebuffer_bind_no_save(GPUFrameBuffer *fb, int slot) |