Upcoming Events
ION Game Conference
5/13 - 5/15 @ Seattle, WA

Nordic Game 2008
5/14 - 5/15 @ Malmö, Sweden

CoGames 2008: The 1st International Workshop on Collaborative Games
5/19 - 5/23 @ Irvine, CA

Vancouver International Games Summit
5/21 - 5/22 @ Vancouver, Canada

More events...


Quick Stats
4777 people currently visiting GDNet.
2172 articles in the reference section.

Help us fight cancer!
Join SETI Team GDNet!



Link to us

  search:   

OpenGL FrameBuffer Object 101



Contents
  Introduction
  Adding a Depth Buffer
  Adding a Texture To Render To
  Rendering to Texture
  Using The Rendered To Texture
  Cleaning Up

  Source code
  Printable version
  Discuss this article

The Series
  OpenGL Frame Buffer Object 101
  OpenGL Frame Buffer Object 201

Introduction

The Frame Buffer Object (FBO) extension was introduced to make Render to Texture objects much more efficient and much easier to perform when compared with the copying or pbuffer alternatives.

In this little article I’m going to give you a quick over view of how to use this extension and some things to keep in mind when using it so you can add faster Render to Texture functionality to your OpenGL programs.

Setting Up

As with the other objects in OpenGL (texture object, pixel buffer objects and vertex buffer object) before you can use a FBO you have to create a valid handle to it:

GLuint fbo;
glGenFramebuffersEXT(1, &fbo);

To perform any operations on a FBO you need to bind it, much like you would a VBO or texture, so that the operations can be performed on it, this is done via the following code

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);

The first parameter is the ‘target’ you wish to bind the framebuffer to, right now the only target you can use is the one indicated above however it is possible future extensions might allow you to bind it somewhere else. The fbo variable holds the handle to the FBO we requested earlier. To perform any FBO related operations you need to have a FBO bound or the calls will fail.





Adding a Depth Buffer