mesa: move check_begin/end_texture_render() calls
authorbrian <brian@cvp965.(none)>
Tue, 10 Nov 2009 23:00:35 +0000 (16:00 -0700)
committerbrian <brian@cvp965.(none)>
Wed, 11 Nov 2009 01:09:13 +0000 (18:09 -0700)
src/mesa/main/fbobject.c

index 9bf43416a6587b33f23f7fee39877508e59b079f..6d8d1876d6eab3a8519269e3aa685f7f35e20033 100644 (file)
@@ -1288,26 +1288,28 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
       }
       else {
          FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+
          _mesa_reference_framebuffer(&ctx->ReadBuffer, newReadFb);
       }
    }
 
    if (bindDrawBuf) {
-      if (oldDrawFb->Name != 0) {
-         check_end_texture_render(ctx, ctx->DrawBuffer);
-      }
-
       if (oldDrawFb == newDrawFb) {
          bindDrawBuf = GL_FALSE; /* no change */
       }
       else {
          FLUSH_VERTICES(ctx, _NEW_BUFFERS);
-         _mesa_reference_framebuffer(&ctx->DrawBuffer, newDrawFb);
-      }
 
-      if (newDrawFb->Name != 0) {
-         /* check if newly bound framebuffer has any texture attachments */
-         check_begin_texture_render(ctx, newDrawFb);
+         if (oldDrawFb->Name != 0) {
+            check_end_texture_render(ctx, oldDrawFb);
+         }
+
+         if (newDrawFb->Name != 0) {
+            /* check if newly bound framebuffer has any texture attachments */
+            check_begin_texture_render(ctx, newDrawFb);
+         }
+
+         _mesa_reference_framebuffer(&ctx->DrawBuffer, newDrawFb);
       }
    }