PDA

View Full Version : GL_EXT_framebuffer_object problem INCOMPLETE_ MISSING_ ATTACHMENT



snowman
04-14-2006, 02:10 AM
I want to render to texture using GL_EXT_framebuffer_object here is my code



glGenTextures(1, &g_color);
glBindTexture(GL_TEXTURE_2D, g_color);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);

// Create an FBO
glGenFramebuffersEXT(1, &g_fbo);
// Bind the FBO and attach color texture to it
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, g_fbo);

// Attach 2D color buffer
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, g_color, 0);then i do

GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);bu t it returns
GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT

what i am doing wrong?

when drawing i do the next

// bind framebuffer
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, g_fbo);
// render to texture
// ...
// unbind framebuffer
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, );
// draw scene
// ...
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, g_color);
// draw quad with this texture
// ...

Andrew Adinetz
04-14-2006, 02:25 AM
Is the depth test enabled in your code? If so, you will have to attach something (either a depth texture or a depth renderbuffer) to DEPTH_ATTACHMENT_EXT attachment point.

snowman
04-14-2006, 02:27 AM
thanks i will try

snowman
04-14-2006, 02:36 AM
i've created depth buffer

// Create depth buffer
glGenRenderbuffersEXT(1, &g_depthBuffer);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, g_depthBuffer);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16, 512, 512);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);

// Attach depth buffer
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, g_depthBuffer);but still hte same result

spasi
04-14-2006, 02:40 AM
Try setting the texture's min & mag filters to GL_LINEAR.

snowman
04-14-2006, 02:50 AM
Thanks a lot! it worked!