nV News Forums

 
 

nV News Forums (http://www.nvnews.net/vbulletin/index.php)
-   NVIDIA Linux (http://www.nvnews.net/vbulletin/forumdisplay.php?f=14)
-   -   Frame buffer object with RGBA+z doesn't work for me.. (http://www.nvnews.net/vbulletin/showthread.php?t=82164)

georg 12-11-06 06:56 AM

Frame buffer object with RGBA+z doesn't work for me..
 
Hi,

am I doing something wrong? This is on a 7900 with 96.31 drivers; I'm trying to get an off-screen buffer with RGBA and Depth. The following results in
GL_FRAMEBUFFER_UNSUPPORTED_EXT. If I leave out the depth buffer bits and just use RGBA, it works just fine.... I thought nvidia said RGBA+Z was supported everywhere?

Code:

GLuint FrameTex;
glGenTextures(1, &FrameTex);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB,FrameTex);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0,
            GL_RGBA, 640, 480, 0,
            GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

GLuint DepthBuffer;
glGenRenderbuffersEXT(1, &DepthBuffer);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, DepthBuffer);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, 640, 480);

GLuint FrameBuffer;
glGenFramebuffersEXT(1, &FrameBuffer);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FrameBuffer);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
                            GL_TEXTURE_RECTANGLE_ARB, FrameTex, 0);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
                                GL_RENDERBUFFER_EXT, DepthBuffer);
 

CheckFramebufferStatus();


georg 12-15-06 12:23 PM

Re: Frame buffer object with RGBA+z doesn't work for me..
 
1 Attachment(s)
Bump. Anyone have any experience with this?

Attached nvidia bug report output.

georg 01-26-07 11:42 AM

Re: Frame buffer object with RGBA+z doesn't work for me..
 
Bump again, last try.

squeen 01-27-07 11:29 AM

Re: Frame buffer object with RGBA+z doesn't work for me..
 
Here are two methods that work for me ( 8800GTX, Quadro FX 4500 & Quadro FX 5500). The first creates and off-screen render target which can be read back using glReadPixels(), the other is a render to texture.
Code:

  GLuint  fb, color_rb, depth_rb, rgba_tex, depth_tex, i;
 
  glGenFramebuffersEXT(1, &fb);
  glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fb );
switch (rtarget->class) {
      case CnFramebufferObjectRenderTargetClass:
        /* depth render buffer */
        glGenRenderbuffersEXT(1, &depth_rb);
        glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, depth_rb );
        glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, rtarget->width, rtarget->height );
        glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb );       
        rtarget->fbo.depth_attach = depth_rb;
        /* color render buffer */
        glGenRenderbuffersEXT(1, &color_rb);
        glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, color_rb );
        glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_RGBA8, rtarget->width, rtarget->height );
        glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, color_rb );
        rtarget->fbo.color_attach[0] = color_rb;
        break;
      case CnRGBATextureRenderTargetClass:
                 
        /* RGBA texture  */
        glGenTextures(1, &rgba_tex);
        glBindTexture(GL_TEXTURE_2D, rgba_tex);
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, rtarget->width, rtarget->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL );
        glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, rgba_tex, 0 );       
        rtarget->fbo.color_attach[0] = rgba_tex;
        cnCheckGLerrors("cnNewFramebufferObject: fbo rgba texture");
       
        /* depth render buffer */
        glGenRenderbuffersEXT(1, &depth_rb);
        glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, depth_rb );
        glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, rtarget->width, rtarget->height );
        glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb );       
        rtarget->fbo.depth_attach = depth_rb;
        cnCheckGLerrors("cnNewFramebufferObject: fbo depth render buffer");
       
        break;
}


georg 01-29-07 07:46 AM

Re: Frame buffer object with RGBA+z doesn't work for me..
 
Thanks for that - that seems to work fine. Upgrading to 97.46 seems to have fixed my code as well! Despite there not being any indication of a change in the nvidia changelog...

Cheers


All times are GMT -5. The time now is 06:58 PM.

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.