Qt:Документация 4.3.2/qglpixelbuffer

Материал из Wiki.crossplatform.ru

Версия от 10:06, 29 января 2009; Root (Обсуждение | вклад)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск
40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

Главная · Все классы · Основные классы · Классы по группам · Модули · Функции

Image:trolltech-logo.png

Содержание

[править] QGLPixelBuffer Class Reference
[модуль QtOpenGL ]

The QGLPixelBuffer class encapsulates an OpenGL pbuffer. Далее...

 #include <QGLPixelBuffer>

Inherits QPaintDevice.

This class was introduced in Qt 4.1.

[править] Открытые функции

  • 12 открытых функций, унаследованных от QPaintDevice

[править] Статические открытые члены

[править] Дополнительные унаследованные члены

  • 1 защищенная функция, унаследованных от QPaintDevice

[править] Подробное описание

The QGLPixelBuffer class encapsulates an OpenGL pbuffer.

Rendering into a pbuffer is normally done using full hardware acceleration. This can be significantly faster than rendering into a QPixmap.

There are three approaches to using this class:

  1. We can draw into the pbuffer and convert it to a QImage using toImage(). This is normally much faster than calling QGLWidget::renderPixmap().
  2. We can draw into the pbuffer and copy the contents into an OpenGL texture using updateDynamicTexture(). This allows us to create dynamic textures and works on all systems with pbuffer support.
  3. On systems that support it, we can bind the pbuffer to an OpenGL texture. The texture is then updated automatically when the pbuffer contents change, eliminating the need for additional copy operations. This is supported only on Windows and Mac OS X systems that provide the render_texture extension.

Pbuffers are provided by the OpenGL pbuffer extension; call hasOpenGLPbuffer() to find out if the system provides pbuffers.

See also Pbuffers Example.


[править] Описание функций-членов

[править]
QGLPixelBuffer::QGLPixelBuffer ( const QSize & size, const QGLFormat & format = QGLFormat::defaultFormat(), QGLWidget * shareWidget = 0 )

Constructs an OpenGL pbuffer of the given 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.

If you intend to bind this pbuffer as a dynamic texture, the width and height components of size must be powers of two (e.g., 512 x 128).

See also size() and format().

[править]
QGLPixelBuffer::QGLPixelBuffer ( int width, int height, const QGLFormat & format = QGLFormat::defaultFormat(), QGLWidget * shareWidget = 0 )

Constructs an OpenGL pbuffer with the width and height. 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.

If you intend to bind this pbuffer as a dynamic texture, the width and height components of size must be powers of two (e.g., 512 x 128).

See also size() and format().

[править]
QGLPixelBuffer::~QGLPixelBuffer () [virtual]

Destroys the pbuffer and frees any allocated resources.

[править]
GLuint QGLPixelBuffer::bindTexture ( const QImage & image, GLenum target = GL_TEXTURE_2D )

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.

Equivalent to calling QGLContext::bindTexture().

See also deleteTexture().

[править]
GLuint QGLPixelBuffer::bindTexture ( const QPixmap & pixmap, GLenum target = GL_TEXTURE_2D )

Эта перегруженная функция предоставлена для удобства.

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

Equivalent to calling QGLContext::bindTexture().

See also deleteTexture().

[править]
GLuint QGLPixelBuffer::bindTexture ( const QString & fileName )

Эта перегруженная функция предоставлена для удобства.

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

Equivalent to calling QGLContext::bindTexture().

See also deleteTexture().

[править]
bool QGLPixelBuffer::bindToDynamicTexture ( GLuint texture_id )

Binds the texture specified by texture_id to this pbuffer. Возвращает true, если всё прошло успешно; в противном случае возвращает false.

The texture must be of the same size and format as the pbuffer.

To unbind the texture, call releaseFromDynamicTexture(). While the texture is bound, it is updated automatically when the pbuffer contents change, eliminating the need for additional copy operations.

Пример:

 QGLPixelBuffer pbuffer(...);
 ...
 pbuffer.makeCurrent();
 GLuint dynamicTexture = pbuffer.generateDynamicTexture();
 pbuffer.bindToDynamicTexture(dynamicTexture);
 ...
 pbuffer.releaseFromDynamicTexture();

Warning: This function uses the render_texture extension, which is currently not supported under X11. An alternative that works on all systems (including X11) is to manually copy the pbuffer contents to a texture using updateDynamicTexture().

Warning: For the bindToDynamicTexture() call to succeed on the Mac OS X, the pbuffer needs a shared context, i.e. the QGLPixelBuffer must be created with a share widget.

See also generateDynamicTexture() and releaseFromDynamicTexture().

[править]
void QGLPixelBuffer::deleteTexture ( GLuint texture_id )

Removes the texture identified by texture_id from the texture cache.

Equivalent to calling QGLContext::deleteTexture().

[править]
bool QGLPixelBuffer::doneCurrent ()

Makes no context the current OpenGL context. Возвращает true, если всё прошло успешно; в противном случае возвращает false.

[править]
QGLFormat QGLPixelBuffer::format () const

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

[править]
GLuint QGLPixelBuffer::generateDynamicTexture () const

Generates and binds a 2D GL texture that is the same size as the pbuffer, and returns the texture's ID. This can be used in conjunction with bindToDynamicTexture() and updateDynamicTexture().

See also size().

[править]
Qt::HANDLE QGLPixelBuffer::handle () const

Returns the native pbuffer handle.

[править]
bool QGLPixelBuffer::hasOpenGLPbuffers () [static]

Returns true if the OpenGL pbuffer extension is present on this system; otherwise returns false.

[править]
bool QGLPixelBuffer::isValid () const

Returns true if this pbuffer is valid; otherwise returns false.

[править]
bool QGLPixelBuffer::makeCurrent ()

Makes this pbuffer the current OpenGL rendering context. Возвращает true, если всё прошло успешно; в противном случае возвращает false.

See also QGLContext::makeCurrent() and doneCurrent().

[править]
void QGLPixelBuffer::releaseFromDynamicTexture ()

Releases the pbuffer from any previously bound texture. Возвращает true, если всё прошло успешно; в противном случае возвращает false.

See also bindToDynamicTexture().

[править]
QSize QGLPixelBuffer::size () const

Returns the size of the pbuffer.

[править]
QImage QGLPixelBuffer::toImage () const

Returns the contents of the pbuffer as a QImage.

[править]
void QGLPixelBuffer::updateDynamicTexture ( GLuint texture_id ) const

Copies the pbuffer contents into the texture specified with texture_id.

The texture must be of the same size and format as the pbuffer.

Пример:

 QGLPixelBuffer pbuffer(...);
 ...
 pbuffer.makeCurrent();
 GLuint dynamicTexture = pbuffer.generateDynamicTexture();
 ...
 pbuffer.updateDynamicTexture(dynamicTexture);

An alternative on Windows and Mac OS X systems that support the render_texture extension is to use bindToDynamicTexture() to get dynamic updates of the texture.

See also generateDynamicTexture() and bindToDynamicTexture().



Copyright © 2007 Trolltech Trademarks
Qt 4.3.2