summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/fbobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/fbobject.c')
-rw-r--r--src/mesa/main/fbobject.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index e3bada5ae89..6f7effcce70 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -29,6 +29,7 @@
*/
+#include "buffers.h"
#include "context.h"
#include "fbobject.h"
#include "framebuffer.h"
@@ -924,7 +925,7 @@ check_end_texture_render(GLcontext *ctx, struct gl_framebuffer *fb)
void GLAPIENTRY
_mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
{
- struct gl_framebuffer *newFb;
+ struct gl_framebuffer *newFb, *newFbread;
GLboolean bindReadBuf, bindDrawBuf;
GET_CURRENT_CONTEXT(ctx);
@@ -984,12 +985,14 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
}
_mesa_HashInsert(ctx->Shared->FrameBuffers, framebuffer, newFb);
}
+ newFbread = newFb;
}
else {
/* Binding the window system framebuffer (which was originally set
* with MakeCurrent).
*/
newFb = ctx->WinSysDrawBuffer;
+ newFbread = ctx->WinSysReadBuffer;
}
ASSERT(newFb);
@@ -999,8 +1002,16 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
* XXX check if re-binding same buffer and skip some of this code.
*/
+ /* for window-framebuffers, re-initialize the fbo values, as they
+ could be wrong (makecurrent with a new drawable while still a fbo
+ was bound will lead to default init fbo values).
+ note that therefore the context ReadBuffer/DrawBuffer values are not
+ valid while fbo's are bound!!! */
if (bindReadBuf) {
- _mesa_reference_framebuffer(&ctx->ReadBuffer, newFb);
+ _mesa_reference_framebuffer(&ctx->ReadBuffer, newFbread);
+ if (!newFbread->Name) {
+ _mesa_readbuffer_update_fields(ctx, ctx->Pixel.ReadBuffer);
+ }
}
if (bindDrawBuf) {
@@ -1008,14 +1019,22 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
check_end_texture_render(ctx, ctx->DrawBuffer);
/* check if time to delete this framebuffer */
_mesa_reference_framebuffer(&ctx->DrawBuffer, newFb);
- if (newFb->Name != 0) {
+ if (!newFb->Name) {
+ GLuint i;
+ GLenum buffers[MAX_DRAW_BUFFERS];
+ for(i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
+ buffers[i] = ctx->Color.DrawBuffer[i];
+ }
+ _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers, buffers, NULL);
+ }
+ else {
/* check if newly bound framebuffer has any texture attachments */
check_begin_texture_render(ctx, newFb);
}
}
if (ctx->Driver.BindFramebuffer) {
- ctx->Driver.BindFramebuffer(ctx, target, newFb);
+ ctx->Driver.BindFramebuffer(ctx, target, newFb, newFbread);
}
}