Home · All Classes · Main Classes · Grouped Classes · Modules · Functions

QGLPbuffer Class Reference
[QtOpenGL module]

The QGLPbuffer class encapsulates an OpenGL pixel buffer. More...

#include <QGLPbuffer>

Inherits QPaintDevice.

This class was introduced in Qt 4.1.

Public Functions

Static Public Members


Detailed Description

The QGLPbuffer class encapsulates an OpenGL pixel buffer.

QGLPbuffer provides functionality for creating and managing an OpenGL pixel buffer (pbuffer). A pixel buffer can be rendered into using full hardware acceleration. This is usually much faster than rendering into a system pixmap, where software rendering is often used. Under Windows and on Mac OS X it is also possible to bind the pixel buffer directly as a texture using the render_texture extension, thus eliminating the need for additional copy operations to generate dynamic textures.

Note that when making use of the render_texture extension, the well known power-of-2 rule applies to the size of the buffer. If the size of the buffer is a non-power of 2 size, it can not be bound to a texture.

See also opengl/pbuffers.


Member Function Documentation

QGLPbuffer::QGLPbuffer ( const QSize & size, const QGLFormat & format = QGLFormat::defaultFormat(), QGLWidget * shareWidget = 0 )

Constructs an OpenGL pbuffer of the size size. If no format is specified the default format is used. If the shareWidget parameter points to a valid QGLWidget, the pbuffer will share its context with shareWidget.

QGLPbuffer::~QGLPbuffer ()   [virtual]

Destroys the QGLPbuffer and frees its resources.

bool QGLPbuffer::bind ( GLuint texture_id )

Binds the texture specified with texture_id to this buffer. Returns true on success, false otherwise.

This function uses the render_texture extension, which is currently not supported under X11. Under X11 you can achieve the same by copying the buffer contents to a texture after drawing into the buffer using copyToTexture().

For the bind() call to succeed on the Mac, the pbuffer needs a shared context, i.e. the QGLPbuffer have to be created with a share widget.

GLuint QGLPbuffer::bindTexture ( const QImage & image, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA8 )

Generates and binds a 2D GL texture to the current context, based on image. The generated texture id is returned and can be used in later glBindTexture() calls.

The target parameter specifies the texture target. The format parameter sets the internal format for the texture.

Equivalent to calling QGLContext::bindTexture().

See also deleteTexture().

GLuint QGLPbuffer::bindTexture ( const QPixmap & pixmap, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA8 )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Generates and binds a 2D GL texture based on pixmap.

Equivalent to calling QGLContext::bindTexture().

See also deleteTexture().

GLuint QGLPbuffer::bindTexture ( const QString & fileName )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Reads the DirectDrawSurface (DDS) compressed file fileName and generates a 2D GL texture from it.

Equivalent to calling QGLContext::bindTexture().

See also deleteTexture().

void QGLPbuffer::copyToTexture ( GLuint texture_id, GLint format = GL_RGBA8 )

This is a convenience function that copies the buffer contents (using glCopyTexImage2D()) into the texture specified with texture_id, which has the internal format format. The default internal format is GL_RGBA8.

void QGLPbuffer::deleteTexture ( GLuint texture_id )

Removes the texture identified by texture_id from the texture cache.

Equivalent to calling QGLContext::deleteTexture().

bool QGLPbuffer::doneCurrent ()

Makes no context the current GL context. Returns true on success, false otherwise.

QGLFormat QGLPbuffer::format () const

Returns the format of the pbuffer. The format may be different from the one that was requested.

GLuint QGLPbuffer::generateTexture ( GLint format = GL_RGBA8 )

This is a convenience function that generates and binds a 2D GL texture that is the same size as the buffer, using format as the internal texture format. The default internal format of the generated texture is GL_RGBA8. The generated texture id is returned.

Qt::HANDLE QGLPbuffer::handle () const

Returns the native pbuffer handle.

bool QGLPbuffer::hasPbuffers ()   [static]

Returns true if pbuffers are supported on this system, otherwise false.

bool QGLPbuffer::isValid () const

Returns true if this buffer is valid.

bool QGLPbuffer::makeCurrent ()

Makes this pbuffer the current GL rendering context. Returns true on success, false otherwise.

bool QGLPbuffer::release ()

Releases the buffer from any previously bound texture. Returns true on success, false otherwise.

This function uses the render_texture extension, which is currently not supported under X11.

QSize QGLPbuffer::size () const

Returns the size of the buffer.

QImage QGLPbuffer::toImage () const

Returns the contents of the buffer as a QImage.


Copyright © 2005 Trolltech Trademarks
Qt 4.1.0-rc1