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  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QOpenGLFramebufferObject Class

The QOpenGLFramebufferObject class encapsulates an OpenGL framebuffer object. More...

 #include <QOpenGLFramebufferObject>

This class was introduced in Qt 5.0.

Public Types

enum Attachment { NoAttachment, CombinedDepthStencil, Depth }

Public Functions

QOpenGLFramebufferObject(const QSize & size, GLenum target = GL_TEXTURE_2D)
QOpenGLFramebufferObject(int width, int height, GLenum target = GL_TEXTURE_2D)
QOpenGLFramebufferObject(const QSize & size, const QOpenGLFramebufferObjectFormat & format)
QOpenGLFramebufferObject(int width, int height, const QOpenGLFramebufferObjectFormat & format)
QOpenGLFramebufferObject(int width, int height, Attachment attachment, GLenum target = GL_TEXTURE_2D, GLenum internal_format = GL_RGBA8)
QOpenGLFramebufferObject(const QSize & size, Attachment attachment, GLenum target = GL_TEXTURE_2D, GLenum internal_format = GL_RGBA8)
virtual ~QOpenGLFramebufferObject()
Attachment attachment() const
bool bind()
QOpenGLFramebufferObjectFormat format() const
GLuint handle() const
int height() const
bool isBound() const
bool isValid() const
bool release()
void setAttachment(Attachment attachment)
QSize size() const
GLuint texture() const
QImage toImage() const
int width() const

Static Public Members

void blitFramebuffer(QOpenGLFramebufferObject * target, const QRect & targetRect, QOpenGLFramebufferObject * source, const QRect & sourceRect, GLbitfield buffers = GL_COLOR_BUFFER_BIT, GLenum filter = GL_NEAREST)
void blitFramebuffer(QOpenGLFramebufferObject * target, QOpenGLFramebufferObject * source, GLbitfield buffers = GL_COLOR_BUFFER_BIT, GLenum filter = GL_NEAREST)
bool hasOpenGLFramebufferBlit()
bool hasOpenGLFramebufferObjects()

Detailed Description

The QOpenGLFramebufferObject class encapsulates an OpenGL framebuffer object.

The QOpenGLFramebufferObject 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 OpenGL calls, or both. This surface can be bound and used as a regular texture in your own OpenGL drawing code. By default, the QOpenGLFramebufferObject class generates a 2D OpenGL texture (using the GL_TEXTURE_2D target), which is used as the internal rendering target.

It is important to have a current OpenGL context when creating a QOpenGLFramebufferObject, otherwise initialization will fail.

When using a QPainter to paint to a QOpenGLFramebufferObject you should take care that the QOpenGLFramebufferObject is created with the CombinedDepthStencil attachment for QPainter to be able to render correctly. Note that you need to create a QOpenGLFramebufferObject with more than one sample per pixel for primitives to be antialiased when drawing using a QPainter. To create a multisample framebuffer object you should use one of the constructors that take a QOpenGLFramebufferObject parameter, and set the QOpenGLFramebufferObject::samples() property to a non-zero value.

For multisample framebuffer objects a color render buffer is created, otherwise a texture with the specified texture target is created. The color render buffer or texture will have the specified internal format, and will be bound to the GL_COLOR_ATTACHMENT0 attachment in the framebuffer object.

If you want to use a framebuffer object with multisampling enabled as a texture, you first need to copy from it to a regular framebuffer object using QOpenGLContext::blitFramebuffer().

Threading

As of Qt 4.8, it's possible to draw into a QOpenGLFramebufferObject using a QPainter in a separate thread. Note that OpenGL 2.0 or OpenGL ES 2.0 is required for this to work.

Member Type Documentation

enum QOpenGLFramebufferObject::Attachment

This enum type is used to configure the depth and stencil buffers attached to the framebuffer object when it is created.

ConstantValueDescription
QOpenGLFramebufferObject::NoAttachment0No attachment is added to the framebuffer object. Note that the OpenGL depth and stencil tests won't work when rendering to a framebuffer object without any depth or stencil buffers. This is the default value.
QOpenGLFramebufferObject::CombinedDepthStencil1If the GL_EXT_packed_depth_stencil extension is present, a combined depth and stencil buffer is attached. If the extension is not present, only a depth buffer is attached.
QOpenGLFramebufferObject::Depth2A depth buffer is attached to the framebuffer object.

See also attachment().

Member Function Documentation

QOpenGLFramebufferObject::QOpenGLFramebufferObject(const QSize & size, GLenum target = GL_TEXTURE_2D)

Constructs an OpenGL framebuffer object and binds a 2D OpenGL texture to the buffer of the size size. The texture is bound to the GL_COLOR_ATTACHMENT0 target in the framebuffer object.

The target parameter is used to specify the OpenGL texture target. The default target is GL_TEXTURE_2D. Keep in mind that GL_TEXTURE_2D textures must have a power of 2 width and height (e.g. 256x512), unless you are using OpenGL 2.0 or higher.

By default, no depth and stencil buffers are attached. This behavior can be toggled using one of the overloaded constructors.

The default internal texture format is GL_RGBA8 for desktop OpenGL, and GL_RGBA for OpenGL/ES.

It is important that you have a current OpenGL context set when creating the QOpenGLFramebufferObject, otherwise the initialization will fail.

See also size(), texture(), and attachment().

QOpenGLFramebufferObject::QOpenGLFramebufferObject(int width, int height, GLenum target = GL_TEXTURE_2D)

This is an overloaded function.

Constructs an OpenGL framebuffer object and binds a 2D OpenGL texture to the buffer of the given width and height.

See also size() and texture().

QOpenGLFramebufferObject::QOpenGLFramebufferObject(const QSize & size, const QOpenGLFramebufferObjectFormat & format)

This is an overloaded function.

Constructs an OpenGL framebuffer object of the given size based on the supplied format.

QOpenGLFramebufferObject::QOpenGLFramebufferObject(int width, int height, const QOpenGLFramebufferObjectFormat & format)

This is an overloaded function.

Constructs an OpenGL framebuffer object of the given width and height based on the supplied format.

QOpenGLFramebufferObject::QOpenGLFramebufferObject(int width, int height, Attachment attachment, GLenum target = GL_TEXTURE_2D, GLenum internal_format = GL_RGBA8)

This is an overloaded function.

Constructs an OpenGL framebuffer object and binds a texture to the buffer of the given width and height.

The attachment parameter describes the depth/stencil buffer configuration, target the texture target and internal_format the internal texture format. The default texture target is GL_TEXTURE_2D, while the default internal format is GL_RGBA8 for desktop OpenGL and GL_RGBA for OpenGL/ES.

See also size(), texture(), and attachment().

QOpenGLFramebufferObject::QOpenGLFramebufferObject(const QSize & size, Attachment attachment, GLenum target = GL_TEXTURE_2D, GLenum internal_format = GL_RGBA8)

This is an overloaded function.

Constructs an OpenGL framebuffer object and binds a texture to the buffer of the given size.

The attachment parameter describes the depth/stencil buffer configuration, target the texture target and internal_format the internal texture format. The default texture target is GL_TEXTURE_2D, while the default internal format is GL_RGBA8 for desktop OpenGL and GL_RGBA for OpenGL/ES.

See also size(), texture(), and attachment().

QOpenGLFramebufferObject::~QOpenGLFramebufferObject() [virtual]

Destroys the framebuffer object and frees any allocated resources.

Attachment QOpenGLFramebufferObject::attachment() const

Returns the status of the depth and stencil buffers attached to this framebuffer object.

See also setAttachment().

bool QOpenGLFramebufferObject::bind()

Switches rendering from the default, windowing system provided framebuffer to this framebuffer object. Returns true upon success, false otherwise.

See also release().

void QOpenGLFramebufferObject::blitFramebuffer(QOpenGLFramebufferObject * target, const QRect & targetRect, QOpenGLFramebufferObject * source, const QRect & sourceRect, GLbitfield buffers = GL_COLOR_BUFFER_BIT, GLenum filter = GL_NEAREST) [static]

Blits from the sourceRect rectangle in the source framebuffer object to the targetRect rectangle in the target framebuffer object.

If source or target is 0, the default framebuffer will be used instead of a framebuffer object as source or target respectively.

The buffers parameter should be a mask consisting of any combination of GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, and GL_STENCIL_BUFFER_BIT. Any buffer type that is not present both in the source and target buffers is ignored.

The sourceRect and targetRect rectangles may have different sizes; in this case buffers should not contain GL_DEPTH_BUFFER_BIT or GL_STENCIL_BUFFER_BIT. The filter parameter should be set to GL_LINEAR or GL_NEAREST, and specifies whether linear or nearest interpolation should be used when scaling is performed.

If source equals target a copy is performed within the same buffer. Results are undefined if the source and target rectangles overlap and have different sizes. The sizes must also be the same if any of the framebuffer objects are multisample framebuffers.

Note that the scissor test will restrict the blit area if enabled.

This function will have no effect unless hasOpenGLFramebufferBlit() returns true.

See also hasOpenGLFramebufferBlit().

void QOpenGLFramebufferObject::blitFramebuffer(QOpenGLFramebufferObject * target, QOpenGLFramebufferObject * source, GLbitfield buffers = GL_COLOR_BUFFER_BIT, GLenum filter = GL_NEAREST) [static]

This is an overloaded function.

Convenience overload to blit between two framebuffer objects.

QOpenGLFramebufferObjectFormat QOpenGLFramebufferObject::format() const

Returns the format of this framebuffer object.

GLuint QOpenGLFramebufferObject::handle() const

Returns the OpenGL framebuffer object handle for this framebuffer object (returned by the glGenFrameBuffersEXT() function). This handle can be used to attach new images or buffers to the framebuffer. The user is responsible for cleaning up and destroying these objects.

bool QOpenGLFramebufferObject::hasOpenGLFramebufferBlit() [static]

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

See also blitFramebuffer().

bool QOpenGLFramebufferObject::hasOpenGLFramebufferObjects() [static]

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

int QOpenGLFramebufferObject::height() const

Returns the height of the framebuffer object attachments.

bool QOpenGLFramebufferObject::isBound() const

Returns true if the framebuffer object is currently bound to a context, otherwise false is returned.

bool QOpenGLFramebufferObject::isValid() const

Returns true if the framebuffer object is valid.

The framebuffer can become invalid if the initialization process fails, the user attaches an invalid buffer to the framebuffer object, or a non-power of two width/height is specified as the texture size if the texture target is GL_TEXTURE_2D. The non-power of two limitation does not apply if the OpenGL version is 2.0 or higher, or if the GL_ARB_texture_non_power_of_two extension is present.

The framebuffer can also become invalid if the QOpenGLContext that the framebuffer was created within is destroyed and there are no other shared contexts that can take over ownership of the framebuffer.

bool QOpenGLFramebufferObject::release()

Switches rendering back to the default, windowing system provided framebuffer. Returns true upon success, false otherwise.

See also bind().

void QOpenGLFramebufferObject::setAttachment(Attachment attachment)

Sets the attachments of the framebuffer object.

This can be used to free or reattach the depth and stencil buffer attachments as needed.

See also attachment().

QSize QOpenGLFramebufferObject::size() const

Returns the size of the texture attached to this framebuffer object.

GLuint QOpenGLFramebufferObject::texture() const

Returns the texture id for the texture attached as the default rendering target in this framebuffer object. This texture id can be bound as a normal texture in your own OpenGL code.

If a multisample framebuffer object is used then the value returned from this function will be invalid.

QImage QOpenGLFramebufferObject::toImage() const

Returns the contents of this framebuffer object as a QImage.

int QOpenGLFramebufferObject::width() const

Returns the width of the framebuffer object attachments.

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 5.0-snapshot
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