Search
lxdream.org :: lxdream :: r877:8331f4aa3616
lxdream 0.9.1
released Jun 29
Download Now
changeset877:8331f4aa3616
parent876:78cd32021472
child878:c498ba66e851
authornkeynes
dateThu Oct 16 12:06:24 2008 +0000 (15 years ago)
Fix bound check on number of framebuffers allocated
Fix repurposing framebuffers to clear out previous attachments to prevent
dimension erros.
src/drivers/gl_fbo.c
1.1 --- a/src/drivers/gl_fbo.c Thu Oct 16 04:46:33 2008 +0000
1.2 +++ b/src/drivers/gl_fbo.c Thu Oct 16 12:06:24 2008 +0000
1.3 @@ -129,7 +129,19 @@
1.4
1.5 static void gl_fbo_setup_framebuffer( int bufno, int width, int height )
1.6 {
1.7 + int i;
1.8 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo[bufno].fb_id);
1.9 +
1.10 + /* Clear out any existing texture attachments */
1.11 + for( i=0; i<gl_fbo_max_attachments; i++ ) {
1.12 + if( fbo[bufno].tex_ids[i] != -1 ) {
1.13 + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, ATTACHMENT_POINT(i),
1.14 + GL_TEXTURE_RECTANGLE_ARB, 0, 0);
1.15 + fbo[bufno].tex_ids[i] = -1;
1.16 + }
1.17 + }
1.18 +
1.19 + /* Setup the renderbuffers */
1.20 if( gl_fbo_have_packed_stencil ) {
1.21 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fbo[bufno].depth_id);
1.22 glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, width, height);
1.23 @@ -165,7 +177,7 @@
1.24 }
1.25 if( bufno == -1 ) {
1.26 bufno = last_used_fbo + 1;
1.27 - if( bufno > MAX_FRAMEBUFFERS ) {
1.28 + if( bufno >= MAX_FRAMEBUFFERS ) {
1.29 bufno = 0;
1.30 }
1.31 last_used_fbo = bufno;
.