Jump to content
  • Advertisement
Sign in to follow this  
ic0de

Using FBO's in GLSL

This topic is 2562 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

Does anybody know how or know a tutorial on using FBO's in GLSL so that I can us effects like Gaussian blur?


here's what I have now to set up the FBO but its probably wrong.

void createframebuffer()
{
GLuint fboId;

GLuint screentex;

glGenTextures(1, &screentex);
glBindTexture(GL_TEXTURE_2D, screentex);

glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, screen->w, screen->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0 );

glGenFramebuffersEXT(1, &fboId);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboId);

glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);

glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,GL_TEXTURE_2D, screentex, 0);

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}



Can anybody tell me what I did wrong and how to access it from my shader?

thanks.

Share this post


Link to post
Share on other sites
Advertisement
FBO needs a depth buffer.
You cant access an FBO from glsl. You can access a texture. But you need to unbind the FBO (release the texture) so that you can use it later.

gaussian blur:
Copy the scene to a texture.
Bind that texture. Bind an FBO which holds texture2.
Using texture, you will blur it and write it into the FBO/texture2.
Unbind the FBO and use the regular render to screen. Bind texture2, apply second blur and that will output to the screen.

Share this post


Link to post
Share on other sites
http://www.opengl.org/wiki/Common_Mistakes#Creating_a_Texture

http://www.opengl.org/wiki/Framebuffer_Object_Examples

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!