nV News Forums

 
 

nV News Forums (http://www.nvnews.net/vbulletin/index.php)
-   NVIDIA Linux (http://www.nvnews.net/vbulletin/forumdisplay.php?f=14)
-   -   Black surfaces with GL_RENDERBUFFER_EXT (http://www.nvnews.net/vbulletin/showthread.php?t=94481)

Ian McLean 07-07-07 04:09 PM

Black surfaces with GL_RENDERBUFFER_EXT
 
I have this code for making an offscreen buffer:

Code:

GL_VERIFY(glGenFramebuffersEXT(1, &m_frameBuffer));
GL_VERIFY(glGenTextures(1, &m_colorTexture));
GL_VERIFY(glBindTexture(GL_TEXTURE_2D, m_colorTexture));
GL_VERIFY(glEnable(GL_TEXTURE_2D));
GL_VERIFY(glTexImage2D(GL_TEXTURE_2D, 0, m_color, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0));
GL_VERIFY(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
GL_VERIFY(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
GL_VERIFY(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
GL_VERIFY(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
GLint prevFrameBuffer = 0;
GL_VERIFY(glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prevFrameBuffer));
GL_VERIFY(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_frameBuffer));
GL_VERIFY(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_colorTexture, 0));
GL_VERIFY(glGenTextures(1, &m_depthTexture));
GL_VERIFY(glBindTexture(GL_TEXTURE_2D, m_depthTexture));
GL_VERIFY(glTexImage2D(GL_TEXTURE_2D, 0, m_depth, m_width, m_height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0));
GL_VERIFY(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
GL_VERIFY(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
GL_VERIFY(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
GL_VERIFY(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
GL_VERIFY(glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE));
GL_VERIFY(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, m_depthTexture, 0));
_RendCheckFramebufferStatus();
GL_VERIFY(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, prevFrameBuffer));

That works fine. However, when I modify it to this:

Code:

GL_VERIFY(glGenFramebuffersEXT(1, &m_frameBuffer));
GL_VERIFY(glGenTextures(1, &m_colorTexture));
GL_VERIFY(glBindTexture(GL_TEXTURE_2D, m_colorTexture));
GL_VERIFY(glEnable(GL_TEXTURE_2D));
GL_VERIFY(glTexImage2D(GL_TEXTURE_2D, 0, m_color, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0));
GL_VERIFY(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
GL_VERIFY(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
GL_VERIFY(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
GL_VERIFY(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
GLint prevFrameBuffer = 0;
GLint prevRenderBuffer = 0;
GL_VERIFY(glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prevFrameBuffer));
GL_VERIFY(glGetIntegerv(GL_RENDERBUFFER_BINDING_EXT, &prevRenderBuffer));
GL_VERIFY(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_frameBuffer));
GL_VERIFY(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_colorTexture, 0));
GL_VERIFY(glGenRenderbuffersEXT(1, &m_depthTexture));
GL_VERIFY(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_depthTexture));
GL_VERIFY(glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, m_width, m_height));
GL_VERIFY(glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthTexture));
_RendCheckFramebufferStatus();
GL_VERIFY(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, prevFrameBuffer));
GL_VERIFY(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, prevRenderBuffer));

I start to have problems.

Whenever my application's window size changes, I delete and recreate about a half dozen of these buffers, of various sizes. With the second implementation, after a few hundred delete+creates (eg, resizing the window border around the screen for a few seconds), everything goes black. No asserts from GL_VERIFY (which checks glGetError for all GL calls in my app), and glCheckFramebufferStatusEXT still returns GL_FRAMEBUFFER_COMPLETE_EXT when I bind the buffer targets each frame.

The second snippet runs under Windows without any problems.

This looks a lot like the 'Beryl-black-window' problem. I couldn't find any technical description of it to confirm, though. I've no problem using my first snippet of code until the next driver rev if that's the case (I'm going to want render-to-depth-texture for shadow maps eventually, anyway).

Can anyone confirm that, or see any problems with either piece of code? If not I'll bother NVIDIA with a bug report.

Thanks


All times are GMT -5. The time now is 12:08 PM.

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