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);
but 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
// ...