Fix frame-buffer texture creation
authorClément Foucault <foucault.clem@gmail.com>
Fri, 20 Apr 2018 18:51:54 +0000 (20:51 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 20 Apr 2018 18:57:28 +0000 (20:57 +0200)
- disable depth buffer didn't work.
- push/pop viewport bit was needed.

source/blender/gpu/intern/gpu_framebuffer.c

index cb23b436fcbfb68939ef72de9540b1c574e8403c..73a1f14b9f6b9f951863963b0c1d2e7f14228946 100644 (file)
@@ -664,11 +664,13 @@ GPUOffScreen *GPU_offscreen_create(int width, int height, int samples, bool dept
                ofs->depth = GPU_texture_create_depth_with_stencil_multisample(width, height, samples, err_out);
        }
 
-       if (!ofs->depth || !ofs->color) {
+       if ((depth && !ofs->depth) || !ofs->color) {
                GPU_offscreen_free(ofs);
                return NULL;
        }
-       
+
+       gpuPushAttrib(GPU_VIEWPORT_BIT);
+
        GPU_framebuffer_ensure_config(&ofs->fb, {
                GPU_ATTACHMENT_TEXTURE(ofs->depth),
                GPU_ATTACHMENT_TEXTURE(ofs->color)
@@ -677,11 +679,14 @@ GPUOffScreen *GPU_offscreen_create(int width, int height, int samples, bool dept
        /* check validity at the very end! */
        if (!GPU_framebuffer_check_valid(ofs->fb, err_out)) {
                GPU_offscreen_free(ofs);
+               gpuPopAttrib();
                return NULL;            
        }
 
        GPU_framebuffer_restore();
 
+       gpuPopAttrib();
+
        return ofs;
 }