Skip to content

PythonQt.QtOpenGL.QGLFramebufferObject

QGLFramebufferObject

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

Detailed Description

The 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 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 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 QGLFramebufferObject, otherwise initialization will fail.

OpenGL framebuffer objects and pbuffers (see QGLPixelBuffer) can both be used to render to offscreen surfaces, but there are a number of advantages with using framebuffer objects instead of pbuffers:

  1. A framebuffer object does not require a separate rendering context, so no context switching will occur when switching rendering targets. There is an overhead involved in switching targets, but in general it is cheaper than a context switch to a pbuffer.
  2. Rendering to dynamic textures (i.e. render-to-texture functionality) works on all platforms. No need to do explicit copy calls from a render buffer into a texture, as was necessary on systems that did not support the render_texture extension.
  3. It is possible to attach several rendering buffers (or texture objects) to the same framebuffer object, and render to all of them without doing a context switch.
  4. The OpenGL framebuffer extension is a pure GL extension with no system dependant WGL, CGL, or GLX parts. This makes using framebuffer objects more portable.

When using a QPainter to paint to a QGLFramebufferObject you should take care that the QGLFramebufferObject is created with the CombinedDepthStencil attachment for QPainter to be able to render correctly. Note that you need to create a QGLFramebufferObject 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 QGLFramebufferObjectFormat parameter, and set the QGLFramebufferObjectFormat::samples() property to a non-zero value.

When painting to a QGLFramebufferObject using 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().

Threading

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

Note: This class has been deprecated in favor of QOpenGLFramebufferObject.

Source: https://doc.qt.io/archives/qt-5.15/qglframebufferobject.html

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
Attachment attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
CombinedDepthStencil attribute Any (shared captured text)
Depth attribute Any (shared captured text)
NoAttachment attribute Any (shared captured text)
PaintDeviceMetric attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
PdmDepth attribute Any (shared captured text)
PdmDevicePixelRatio attribute Any (shared captured text)
PdmDevicePixelRatioScaled attribute Any (shared captured text)
PdmDpiX attribute Any (shared captured text)
PdmDpiY attribute Any (shared captured text)
PdmHeight attribute Any (shared captured text)
PdmHeightMM attribute Any (shared captured text)
PdmNumColors attribute Any (shared captured text)
PdmPhysicalDpiX attribute Any (shared captured text)
PdmPhysicalDpiY attribute Any (shared captured text)
PdmWidth attribute Any (shared captured text)
PdmWidthMM attribute Any (shared captured text)
__init__ function (self, *args: Any, **kwargs: Any) -> None Native constructor; consult class documentation for supported overloads. (shared captured text)
attachment function (self) -> Any Returns the status of the depth and stencil buffers attached to this framebuffer object.
bind function (self) -> bool X.bind() -> bool
bindDefault function (self) -> bool X.bindDefault() -> bool
blitFramebuffer function (self, target: Any, targetRect: Any, source: Any, sourceRect: Any, buffers: int, filter: int) -> None X.blitFramebuffer(target, targetRect, source, sourceRect, buffers, filter)
className function (self, *args: Any, **kwargs: Any) -> Any Return the classname of the object (shared captured text)
colorCount function (self) -> int X.colorCount() -> int (shared captured text)
delete function (self, *args: Any, **kwargs: Any) -> Any Deletes the C++ object (at your own risk, my friend!) (shared captured text)
depth function (self) -> int X.depth() -> int (shared captured text)
devType function (self) -> int X.devType() -> int
devicePixelRatio function (self) -> int X.devicePixelRatio() -> int (shared captured text)
devicePixelRatioF function (self) -> float X.devicePixelRatioF() -> float (shared captured text)
devicePixelRatioFScale function (self) -> float X.devicePixelRatioFScale() -> float (shared captured text)
drawTexture function (self, point: Any, textureId: int, textureTarget: int) -> None X.drawTexture(point, textureId, textureTarget)
format function (self) -> Any X.format() -> PythonQt.QtOpenGL.QGLFramebufferObjectFormat
handle function (self) -> int X.handle() -> int
hasOpenGLFramebufferBlit function (self) -> bool X.hasOpenGLFramebufferBlit() -> bool
hasOpenGLFramebufferObjects function (self) -> bool X.hasOpenGLFramebufferObjects() -> bool
height function (self) -> int X.height() -> int (shared captured text)
heightMM function (self) -> int X.heightMM() -> int (shared captured text)
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
inherits function (self, *args: Any, **kwargs: Any) -> Any Returns if the class inherits or is of given type name (shared captured text)
initPainter function (self, painter: Any) -> Any (shared captured text)
isBound function (self) -> bool X.isBound() -> bool
isValid function (self) -> bool X.isValid() -> bool
logicalDpiX function (self) -> int X.logicalDpiX() -> int (shared captured text)
logicalDpiY function (self) -> int X.logicalDpiY() -> int (shared captured text)
metric function (self, metric: Any) -> int X.metric(metric) -> int
paintEngine function (self) -> Any X.paintEngine() -> PythonQt.QtGui.QPaintEngine
paintingActive function (self) -> bool X.paintingActive() -> bool (shared captured text)
physicalDpiX function (self) -> int X.physicalDpiX() -> int (shared captured text)
physicalDpiY function (self) -> int X.physicalDpiY() -> int (shared captured text)
redirected function (self, offset: Any) -> Any X.redirected(offset) -> PythonQt.QtGui.QPaintDevice (shared captured text)
release function (self) -> bool X.release() -> bool
sharedPainter function (self) -> Any X.sharedPainter() -> PythonQt.QtGui.QPainter (shared captured text)
size function (self) -> Any X.size() -> PythonQt.QtCore.QSize
texture function (self) -> int X.texture() -> int
toImage function (self) -> Any X.toImage() -> PythonQt.QtGui.QImage
width function (self) -> int X.width() -> int (shared captured text)
widthMM function (self) -> int X.widthMM() -> int (shared captured text)