The PySide.QtOpenGL.QGLFramebufferObject class encapsulates an OpenGL framebuffer object.
The PySide.QtOpenGL.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 PySide.QtGui.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 PySide.QtOpenGL.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 :class:`PySide.QtOpenGL.QGLFramebufferObject` **, otherwise initialization will fail.
OpenGL framebuffer objects and pbuffers (see PySide.QtOpenGL.QGLPixelBuffer ) can both be used to render to offscreen surfaces, but there are a number of advantages with using framebuffer objects instead of pbuffers:
When using a PySide.QtGui.QPainter to paint to a PySide.QtOpenGL.QGLFramebufferObject you should take care that the PySide.QtOpenGL.QGLFramebufferObject is created with the CombinedDepthStencil attachment for PySide.QtGui.QPainter to be able to render correctly. Note that you need to create a PySide.QtOpenGL.QGLFramebufferObject with more than one sample per pixel for primitives to be antialiased when drawing using a PySide.QtGui.QPainter . To create a multisample framebuffer object you should use one of the constructors that take a PySide.QtOpenGL.QGLFramebufferObject parameter, and set the QGLFramebufferObject::samples() property to a non-zero value.
When painting to a PySide.QtOpenGL.QGLFramebufferObject using PySide.QtGui.QPainter , the state of the current GL context will be altered by the paint engine to reflect its needs. Applications should not rely upon the GL state being reset to its original conditions, particularly the current shader program, GL viewport, texture units, and drawing modes.
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 QGLContext::blitFramebuffer().
See also
Framebuffer Object Example
Parameters: |
|
---|
This is an overloaded function.
Constructs an OpenGL framebuffer object of the given size based on the supplied format .
This is an overloaded function.
Constructs an OpenGL framebuffer object of the given width and height based on the supplied format .
This enum type is used to configure the depth and stencil buffers attached to the framebuffer object when it is created.
Constant | Description |
---|---|
QGLFramebufferObject.NoAttachment | No 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. |
QGLFramebufferObject.CombinedDepthStencil | If 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. |
QGLFramebufferObject.Depth | A depth buffer is attached to the framebuffer object. |
Return type: | PySide.QtOpenGL.QGLFramebufferObject.Attachment |
---|
Returns the status of the depth and stencil buffers attached to this framebuffer object.
Return type: | PySide.QtCore.bool |
---|
Switches rendering from the default, windowing system provided framebuffer to this framebuffer object. Returns true upon success, false otherwise.
Return type: | PySide.QtCore.bool |
---|
Switches rendering back to the default, windowing system provided framebuffer. Returns true upon success, false otherwise.
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: |
|
---|
Return type: | PySide.QtOpenGL.QGLFramebufferObjectFormat |
---|
Returns the format of this framebuffer object.
Return type: | long |
---|
Returns the GL 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.
Return type: | PySide.QtCore.bool |
---|
Returns true if the OpenGL GL_EXT_framebuffer_blit extension is present on this system; otherwise returns false.
Return type: | PySide.QtCore.bool |
---|
Returns true if the OpenGL GL_EXT_framebuffer_object extension is present on this system; otherwise returns false.
Return type: | PySide.QtCore.bool |
---|
Returns true if the framebuffer object is currently bound to a context, otherwise false is returned.
Return type: | PySide.QtCore.bool |
---|
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 PySide.QtOpenGL.QGLContext that the framebuffer was created within is destroyed and there are no other shared contexts that can take over ownership of the framebuffer.
Return type: | PySide.QtCore.bool |
---|
Switches rendering back to the default, windowing system provided framebuffer. Returns true upon success, false otherwise.
Return type: | PySide.QtCore.QSize |
---|
Returns the size of the texture attached to this framebuffer object.
Return type: | long |
---|
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 GL code.
If a multisample framebuffer object is used then the value returned from this function will be invalid.
Return type: | PySide.QtGui.QImage |
---|
Returns the contents of this framebuffer object as a PySide.QtGui.QImage .