Skip to main content
gamedev.net
🔒 Locked

Problem setting up framebuffer

Started by Icebraker Sep 16, 2006 at 2:39 PM 0 replies 900+ views
Original Post
Icebraker
Icebraker
Hi, I'm trying to implement framebuffers. I want to draw a picture into my framebuffer, copy it to a texture and use it as an inmput for my fragmentshader. However, when setting up my framebuffer I get the Errormessage : "Error missing attachment". My code looks like this: ... glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB,currentSizeX, currentSizeY, 0, GL_RGBA, GL_FLOAT, NULL); glGenFramebuffersEXT(1, &framebuf); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuf); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, depthMap, 0); glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); if(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)==GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT) { std::cout << "Error missing attatchment" << std::endl; } ... Does anybody see an error or is anything missing? Any help on this is appreciated, Thx, Icebraker
Sepultang
Sepultang
Just to make things clear: framebuffer objects (FBOs) doesn't copy from the framebuffer but rather render directly to a provided texture (to copy the framebuffer use glCopyTexSubImage2D, but you probably don't wanna do that).

I can't really see anything wrong in your fbo-code except that you shouldn't create the texture and fbo each frame. This should be done once, then in the render-function, just do:
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, id);//[render something]glDrawBuffer(oldDrawBuffer);	//reset draw buffer to screenglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);


btw, I guess you have cut off the rest of your texture-creating code? Either way I paste my code for creating a floating point texture. Remember you must set the filtering to nearest neighbor:
 glActiveTexture(m_texUnit); glGenTextures(1, &m_textID); glBindTexture(target, m_textID); glEnable(target);	 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB,currentSizeX, currentSizeY, 0, GL_RGBA, GL_FLOAT, NULL);


Hope that helps!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.