summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/framebuffer.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-10-08 14:41:17 +0000
committerBrian Paul <[email protected]>2005-10-08 14:41:17 +0000
commit474f28e57ca750ca39d7f684904a3c0e69a03f62 (patch)
treeaa9d5d1c9c37bf9a457ed0e77f89eabda631efda /src/mesa/main/framebuffer.c
parent81a22ef53953d950052c7bd5a282e96107a25f24 (diff)
Fix some issues with state updates and renderbuffers. Querying GL_RED_BITS,
etc. after calling glRenderBufferStorageEXT gave undefined results.
Diffstat (limited to 'src/mesa/main/framebuffer.c')
-rw-r--r--src/mesa/main/framebuffer.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index f6322bf4d1c..479f7625684 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -328,23 +328,33 @@ _mesa_update_draw_buffer_bounds(GLcontext *ctx)
void
_mesa_update_framebuffer_visual(struct gl_framebuffer *fb)
{
+ GLuint i;
+
assert(fb->Name != 0);
_mesa_bzero(&fb->Visual, sizeof(fb->Visual));
- fb->Visual.rgbMode = GL_TRUE;
-
- if (fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer) {
- fb->Visual.redBits
- = fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->RedBits;
- fb->Visual.greenBits
- = fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->GreenBits;
- fb->Visual.blueBits
- = fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->BlueBits;
- fb->Visual.alphaBits
- = fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->AlphaBits;
- fb->Visual.rgbBits
- = fb->Visual.redBits + fb->Visual.greenBits + fb->Visual.blueBits;
- fb->Visual.floatMode = GL_FALSE;
+ fb->Visual.rgbMode = GL_TRUE; /* assume this */
+
+ /* find first RGB or CI renderbuffer */
+ for (i = 0; i < BUFFER_COUNT; i++) {
+ if (fb->Attachment[i].Renderbuffer) {
+ const struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer;
+ if (rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB) {
+ fb->Visual.redBits = rb->RedBits;
+ fb->Visual.greenBits = rb->GreenBits;
+ fb->Visual.blueBits = rb->BlueBits;
+ fb->Visual.alphaBits = rb->AlphaBits;
+ fb->Visual.rgbBits = fb->Visual.redBits
+ + fb->Visual.greenBits + fb->Visual.blueBits;
+ fb->Visual.floatMode = GL_FALSE;
+ break;
+ }
+ else if (rb->_BaseFormat == GL_COLOR_INDEX) {
+ fb->Visual.indexBits = rb->IndexBits;
+ fb->Visual.rgbMode = GL_FALSE;
+ break;
+ }
+ }
}
if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) {
@@ -380,8 +390,10 @@ _mesa_update_framebuffer(GLcontext *ctx)
GLuint output;
/* Completeness only matters for user-created framebuffers */
- if (fb->Name != 0)
+ if (fb->Name != 0) {
_mesa_test_framebuffer_completeness(ctx, fb);
+ _mesa_update_framebuffer_visual(fb);
+ }
/*
* Update the list of color drawing renderbuffer pointers.