Jump to content
  • Advertisement
Sign in to follow this  

Problem setting up framebuffer

This topic is 4415 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post

Link to post
Share on other sites
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:

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, id);
//[render something]
glDrawBuffer(oldDrawBuffer); //reset draw buffer to screen
glBindFramebufferEXT(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:

glGenTextures(1, &m_textID);
glBindTexture(target, m_textID);

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!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!