gl_FragData[0] not working
Ok I've been going crazy trying to figure out why my other buffers aren't being drawn to. They worked before but now they're not... My mistake I was making before was that I wasn't attaching a depth buffer so i was getting incorrect depth values because of no depth test. Now that I have a depth buffer as a surface, my attached textures aren't being written to, only my first one.
I have 3 textures and 1 surface attached to my FBO, the first texture is being written to, but not the others, when I draw each to the screen, only the one that's written to gl_FragData[0] has anything. Once I comment out adding my depth buffer, the other textures have images on them, but incorrect depth values...
am I missing something?
You'll need to post some code, specifically your framebuffer initialization and your call to glDrawBuffers.
glGenFramebuffersEXT(1, &m_frameID);glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_frameID);// this loops 3 times but for 3 different textures that I have an object for with different "m_id"sglGenTextures(1, &m_id);glBindTexture(GL_TEXTURE_2D, m_id);glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 640, 480, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);glGenerateMipmapEXT(GL_TEXTURE_2D);// for each iteration of texture, I use GL_COLOR_ATTACHMENT0_EXT, then GL_COLOR_ATTACHMENT1_EXT, then GL_COLOR_ATTACHMENT2_EXTglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_id, 0);// my depth surfaceglGenRenderbuffersEXT(1, &m_bufferID);glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_bufferID);glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA, 640, 480);glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_bufferID);// during rendering I simply justglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_frameID);// then clear, and render my scene through the camera
I think you are missing the glDrawBuffers call after binding the FBO. try something like:
GLenum buffers[] = {GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2};
glDrawBuffers(3, buffers);
GLenum buffers[] = {GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2};
glDrawBuffers(3, buffers);
oh yea, sorry I do have that at the end
glDrawBuffers( m_bufferList.size(), &m_bufferList[0]);
// m_bufferList has GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, and GL_DEPTH_ATTACHMENT.
Do I even need GL_DEPTH_ATTACHMENT in there since I'm not writing to it?
glDrawBuffers( m_bufferList.size(), &m_bufferList[0]);
// m_bufferList has GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, and GL_DEPTH_ATTACHMENT.
Do I even need GL_DEPTH_ATTACHMENT in there since I'm not writing to it?
GL_DEPTH_ATTACHMENT isn't a valid parameter to glDrawBuffers, and that's probably generating a GL error, and thus ignoring the glDrawBuffers call.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement