Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QGLPixelBuffer Class Reference
[QtOpenGL module]

The QGLPixelBuffer class encapsulates an OpenGL pbuffer. More...

 #include <QGLPixelBuffer>

This class is not part of the Qt GUI Framework Edition.

Inherits QPaintDevice.

This class was introduced in Qt 4.1.


Public Functions

QGLPixelBuffer ( const QSize & size, const QGLFormat & format = QGLFormat::defaultFormat(), QGLWidget * shareWidget = 0 )
QGLPixelBuffer ( int width, int height, const QGLFormat & format = QGLFormat::defaultFormat(), QGLWidget * shareWidget = 0 )
virtual ~QGLPixelBuffer ()
GLuint bindTexture ( const QImage & image, GLenum target = GL_TEXTURE_2D )
GLuint bindTexture ( const QPixmap & pixmap, GLenum target = GL_TEXTURE_2D )
GLuint bindTexture ( const QString & fileName )
bool bindToDynamicTexture ( GLuint texture_id )
void deleteTexture ( GLuint texture_id )
bool doneCurrent ()
void drawTexture ( const QRectF & target, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D )
void drawTexture ( const QPointF & point, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D )
QGLFormat format () const
GLuint generateDynamicTexture () const
Qt::HANDLE handle () const
bool isValid () const
bool makeCurrent ()
void releaseFromDynamicTexture ()
QSize size () const
QImage toImage () const
void updateDynamicTexture ( GLuint texture_id ) const

Reimplemented Public Functions

virtual QPaintEngine * paintEngine () const

Static Public Members

bool hasOpenGLPbuffers ()

Reimplemented Protected Functions

virtual int metric ( PaintDeviceMetric metric ) const

Detailed Description

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.


Member Function Documentation

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 )

This is an overloaded function.

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 )

This is an overloaded function.

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

Equivalent to calling QGLContext::bindTexture().

See also deleteTexture().

GLuint QGLPixelBuffer::bindTexture ( const QString & fileName )

This is an overloaded function.

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. Returns true on success; otherwise returns 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.

Example:

 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. Returns true on success; otherwise returns false.

void QGLPixelBuffer::drawTexture ( const QRectF & target, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D )

Draws the given texture, textureId, to the given target rectangle, target, in OpenGL model space. The textureTarget should be a 2D texture target.

Equivalent to the corresponding QGLContext::drawTexture().

This function was introduced in Qt 4.4.

void QGLPixelBuffer::drawTexture ( const QPointF & point, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D )

Draws the given texture, textureId, at the given point in OpenGL model space. The textureTarget parameter should be a 2D texture target.

Equivalent to the corresponding QGLContext::drawTexture().

This function was introduced in Qt 4.4.

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. Returns true on success; otherwise returns false.

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

int QGLPixelBuffer::metric ( PaintDeviceMetric metric ) const   [virtual protected]

Reimplemented from QPaintDevice::metric().

QPaintEngine * QGLPixelBuffer::paintEngine () const   [virtual]

Reimplemented from QPaintDevice::paintEngine().

void QGLPixelBuffer::releaseFromDynamicTexture ()

Releases the pbuffer from any previously bound texture.

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.

Example:

 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().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. Microsoft ouvre aux autres compilateurs C++ AMP, la spécification pour la conception d'applications parallèles C++ utilisant le GPU 22
  2. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  3. RIM : « 13 % des développeurs ont gagné plus de 100 000 $ sur l'AppWord », Qt et open-source au menu du BlackBerry DevCon Europe 0
  4. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 10
  5. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
Page suivante

Le Qt Quarterly au hasard

Logo

Déployer dans le Bazaar

Qt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.6
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web