|  | Home · Overviews · Examples |

# QGLFramebufferObject Class Reference
[com.trolltech.qt.opengl module]

The `QGLFramebufferObject` class encapsulates an OpenGL framebuffer object. More...

Inherits .

## Detailed Description

The `QGLFramebufferObject` class encapsulates an OpenGL framebuffer object.

The `QGLFramebufferObject` class encapsulates an OpenGL framebuffer object, defined by the `GL_EXT_framebuffer_object` extension. In addition it provides a rendering surface that can be painted on with a `QPainter`, rendered to using native GL calls, or both. This surface can be bound and used as a regular texture in your own GL drawing code. By default, the `QGLFramebufferObject` class generates a 2D GL texture (using the `GL_TEXTURE_2D` target), which is used as the internal rendering target.

It is important to have a current GL context when creating a `QGLFramebufferObject`, otherwise initialization will fail.

OpenGL framebuffer objects and pbuffers (see QGLPixelBuffer) can both be used to render to offscreen surfaces, but there are a number of advantages with using framebuffer objects instead of pbuffers:

1. A framebuffer object does not require a separate rendering context, so no context switching will occur when switching rendering targets. There is an overhead involved in switching targets, but in general it is cheaper than a context switch to a pbuffer.
2. Rendering to dynamic textures (i.e. render-to-texture functionality) works on all platforms. No need to do explicit copy calls from a render buffer into a texture, as was necessary on systems that did not support the `render_texture` extension.
3. It is possible to attach several rendering buffers (or texture objects) to the same framebuffer object, and render to all of them without doing a context switch.
4. The OpenGL framebuffer extension is a pure GL extension with no system dependant WGL, AGL or GLX parts. This makes using framebuffer objects more portable.

Note that `QPainter` antialiasing of drawing primitives will not work when using a `QGLFramebufferObject` as a paintdevice. This is because sample buffers, which are needed for antialiasing, are not yet supported in application-defined framebuffer objects. However, an extension to solve this has already been approved by the OpenGL ARB (`GL_EXT_framebuffer_multisample`), and will most likely be available in the near future.

See also Framebuffer Object Example.