Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.opengl
Class QGLFramebufferObject

    java.lang.Object
      com.trolltech.qt.internal.QSignalEmitterInternal
          com.trolltech.qt.QSignalEmitter
              com.trolltech.qt.QtJambiObject
                  com.trolltech.qt.opengl.QGLFramebufferObject

All Implemented Interfaces:
  QPaintDeviceInterface, QtJambiInterface

    public class QGLFramebufferObject

extends QtJambiObject
implements QPaintDeviceInterface

The `QGLFramebufferObject` class encapsulates an OpenGL framebuffer object. 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, AGL or GLX parts. This makes using framebuffer objects more portable.

Note that primitives drawn to a `QGLFramebufferObject` with `QPainter` will only be antialiased if the `QPainter::HighQualityAntialiasing` render hint is set. This is because there is currently no support for the `GL_EXT_framebuffer_multisample` extension, which is required to do multisample based antialiasing. Also note that the `QPainter::HighQualityAntialiasing` render hint requires the `GL_ARB_fragment_program` extension to work in OpenGL.

See also:
  Framebuffer Object Example.

Nested Class Summary
`static class` | `QGLFramebufferObject.Attachment` This enum type is used to configure the depth and stencil buffers attached to the framebuffer object when it is created.

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal`

Field Summary

Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`currentSender`

Constructor Summary
`QGLFramebufferObject(int width, int height)` Constructs an OpenGL framebuffer object and binds a 2D GL texture to the buffer of the given `width` and `height`.
`QGLFramebufferObject(int width, int height, int target)` Constructs an OpenGL framebuffer object and binds a 2D GL texture to the buffer of the given `width` and `height`.
`QGLFramebufferObject(int width, int height, QGLFramebufferObject.Attachment attachment)` Constructs an OpenGL framebuffer object and binds a texture to the buffer of the given `width` and `height`.
`QGLFramebufferObject(int width, int height, QGLFramebufferObject.Attachment attachment, int target)` Constructs an OpenGL framebuffer object and binds a texture to the buffer of the given `width` and `height`.
`QGLFramebufferObject(int width, int height, QGLFramebufferObject.Attachment attachment, int target, int internal_format)` Constructs an OpenGL framebuffer object and binds a texture to the buffer of the given `width` and `height`.
`QGLFramebufferObject(QSize size)` Constructs an OpenGL framebuffer object and binds a 2D GL texture to the buffer of the size `size`.
`QGLFramebufferObject(QSize size, int target)` Constructs an OpenGL framebuffer object and binds a 2D GL texture to the buffer of the size `size`.
`QGLFramebufferObject(QSize size, QGLFramebufferObject.Attachment attachment)` Constructs an OpenGL framebuffer object and binds a texture to the buffer of the given `size`.
`QGLFramebufferObject(QSize size, QGLFramebufferObject.Attachment attachment, int target)` Constructs an OpenGL framebuffer object and binds a texture to the buffer of the given `size`.
`QGLFramebufferObject(QSize size, QGLFramebufferObject.Attachment attachment, int target, int internal_format)` Constructs an OpenGL framebuffer object and binds a texture to the buffer of the given `size`.

Method Summary
`QGLFramebufferObject.Attachment` | `attachment()` Returns the status of the depth and stencil buffers attached to this framebuffer object.
`boolean` | `bind()` Switches rendering from the default, windowing system provided framebuffer to this framebuffer object.
`int` | `depth()` Returns the bit depth (number of bit planes) of the paint device.
`void` | `drawTexture(QPointF point, int textureId)` Draws the given texture, `textureId`, at the given `point` in OpenGL model space.
`void` | `drawTexture(QPointF point, int textureId, int textureTarget)` Draws the given texture, `textureId`, at the given `point` in OpenGL model space.
`void` | `drawTexture(QRectF target, int textureId)` Draws the given texture, `textureId`, to the given target rectangle, `target`, in OpenGL model space.
`void` | `drawTexture(QRectF target, int textureId, int textureTarget)` Draws the given texture, `textureId`, to the given target rectangle, `target`, in OpenGL model space.
`int` | `handle()` Returns the GL framebuffer object handle for this framebuffer object (returned by the `glGenFrameBuffersEXT()` function).
`static boolean` | `hasOpenGLFramebufferObjects()` Returns true if the OpenGL `GL_EXT_framebuffer_object` extension is present on this system; otherwise returns false.
`int` | `height()` Returns the height of the paint device in default coordinate system units (e.
`int` | `heightMM()` Returns the height of the paint device in millimeters.
`boolean` | `isValid()` Returns true if the framebuffer object is valid.
`int` | `logicalDpiX()` Returns the horizontal resolution of the device in dots per inch, which is used when computing font sizes.
`int` | `logicalDpiY()` Returns the vertical resolution of the device in dots per inch, which is used when computing font sizes.
`int` | `metric(QPaintDevice.PaintDeviceMetric metric)` Returns the metric information for the given paint device `metric`.
`int` | `numColors()` Returns the number of different colors available for the paint device.
`QPaintEngine` | `paintEngine()` Returns a pointer to the paint engine used for drawing on the device.
`boolean` | `paintingActive()` Returns true if the device is currently being painted on, i.
`int` | `physicalDpiX()` Returns the horizontal resolution of the device in dots per inch.
`int` | `physicalDpiY()` Returns the horizontal resolution of the device in dots per inch.
`boolean` | `release()` Switches rendering back to the default, windowing system provided framebuffer.
`QSize` | `size()` Returns the size of the texture attached to this framebuffer object.
`int` | `texture()` Returns the texture id for the texture attached as the default rendering target in this framebuffer object.
`QImage` | `toImage()` Returns the contents of this framebuffer object as a `QImage`.
`int` | `width()` Returns the width of the paint device in default coordinate system units (e.
`int` | `widthMM()` Returns the width of the paint device in millimeters.

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`__qt_signalInitialization`

Methods inherited from class java.lang.Object
`clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Constructor Detail

### QGLFramebufferObject

    public QGLFramebufferObject(QSize size)

  Constructs an OpenGL framebuffer object and binds a 2D GL 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 GL 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`.

  It is important that you have a current GL context set when creating the `QGLFramebufferObject`, otherwise the initialization will fail.

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

### QGLFramebufferObject

    public QGLFramebufferObject(QSize size,
                                int target)

  Constructs an OpenGL framebuffer object and binds a 2D GL 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 GL 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`.

  It is important that you have a current GL context set when creating the `QGLFramebufferObject`, otherwise the initialization will fail.

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

### QGLFramebufferObject

    public QGLFramebufferObject(QSize size,
                                QGLFramebufferObject.Attachment attachment,
                                int target)

  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`.

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

### QGLFramebufferObject

    public QGLFramebufferObject(QSize size,
                                QGLFramebufferObject.Attachment attachment)

  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`.

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

### QGLFramebufferObject

    public QGLFramebufferObject(QSize size,
                                QGLFramebufferObject.Attachment attachment,
                                int target,
                                int internal_format)

  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`.

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

### QGLFramebufferObject

    public QGLFramebufferObject(int width,
                                int height)

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

See also:
  `size()`, and `texture()`.

### QGLFramebufferObject

    public QGLFramebufferObject(int width,
                                int height,
                                int target)

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

See also:
  `size()`, and `texture()`.

### QGLFramebufferObject

    public QGLFramebufferObject(int width,
                                int height,
                                QGLFramebufferObject.Attachment attachment,
                                int target)

  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`.

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

### QGLFramebufferObject

    public QGLFramebufferObject(int width,
                                int height,
                                QGLFramebufferObject.Attachment attachment)

  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`.

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

### QGLFramebufferObject

    public QGLFramebufferObject(int width,
                                int height,
                                QGLFramebufferObject.Attachment attachment,
                                int target,
                                int internal_format)

  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`.

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

Method Detail

### attachment

    public final QGLFramebufferObject.Attachment attachment()

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

### bind

    public final boolean bind()

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

### depth

    public final int depth()

  Returns the bit depth (number of bit planes) of the paint device.

  Specified by:
    `depth` in interface `QPaintDeviceInterface`

### drawTexture

    public final void drawTexture(QPointF point,
                                  int textureId)

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

  The framebuffer object should be bound when calling this function.

  Equivalent to the corresponding `QGLContext::drawTexture()`.

### drawTexture

    public final void drawTexture(QPointF point,
                                  int textureId,
                                  int textureTarget)

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

  The framebuffer object should be bound when calling this function.

  Equivalent to the corresponding `QGLContext::drawTexture()`.

### drawTexture

    public final void drawTexture(QRectF target,
                                  int textureId)

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

  The framebuffer object should be bound when calling this function.

  Equivalent to the corresponding `QGLContext::drawTexture()`.

### drawTexture

    public final void drawTexture(QRectF target,
                                  int textureId,
                                  int textureTarget)

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

  The framebuffer object should be bound when calling this function.

  Equivalent to the corresponding `QGLContext::drawTexture()`.

### handle

    public final int handle()

  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.

### height

    public final int height()

  Returns the height of the paint device in default coordinate system units (e. . pixels for `QPixmap` and `QWidget`).

See also:
  `heightMM()`.

  Specified by:
    `height` in interface `QPaintDeviceInterface`

### heightMM

    public final int heightMM()

  Returns the height of the paint device in millimeters.

See also:
  `height()`.

  Specified by:
    `heightMM` in interface `QPaintDeviceInterface`

### isValid

    public final boolean isValid()

  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 2 width/height is specified as the texture size if the texture target is `GL_TEXTURE_2D`.

### logicalDpiX

    public final int logicalDpiX()

  Returns the horizontal resolution of the device in dots per inch, which is used when computing font sizes. For X11, this is usually the same as could be computed from `widthMM()`.

  Note that if the `logicalDpiX()` doesn't equal the `physicalDpiX()`, the corresponding `QPaintEngine` must handle the resolution mapping.

See also:
  `logicalDpiY()`, and `physicalDpiX()`.

  Specified by:
    `logicalDpiX` in interface `QPaintDeviceInterface`

### logicalDpiY

    public final int logicalDpiY()

  Returns the vertical resolution of the device in dots per inch, which is used when computing font sizes. For X11, this is usually the same as could be computed from `heightMM()`.

  Note that if the `logicalDpiY()` doesn't equal the `physicalDpiY()`, the corresponding `QPaintEngine` must handle the resolution mapping.

See also:
  `logicalDpiX()`, and `physicalDpiY()`.

  Specified by:
    `logicalDpiY` in interface `QPaintDeviceInterface`

### numColors

    public final int numColors()

  Returns the number of different colors available for the paint device. Since this value is an int, it will not be sufficient to represent the number of colors on 32 bit displays, in this case INT_MAX is returned instead.

  Specified by:
    `numColors` in interface `QPaintDeviceInterface`

### paintingActive

    public final boolean paintingActive()

  Returns true if the device is currently being painted on, i. . someone has called `QPainter::begin()` but not yet called `QPainter::end()` for this device; otherwise returns false.

See also:
  `QPainter::isActive()`.

  Specified by:
    `paintingActive` in interface `QPaintDeviceInterface`

### physicalDpiX

    public final int physicalDpiX()

  Returns the horizontal resolution of the device in dots per inch. For example, when printing, this resolution refers to the physical printer's resolution. The logical DPI on the other hand, refers to the resolution used by the actual paint engine.

  Note that if the `physicalDpiX()` doesn't equal the `logicalDpiX()`, the corresponding `QPaintEngine` must handle the resolution mapping.

See also:
  `physicalDpiY()`, and `logicalDpiX()`.

  Specified by:
    `physicalDpiX` in interface `QPaintDeviceInterface`

### physicalDpiY

    public final int physicalDpiY()

  Returns the horizontal resolution of the device in dots per inch. For example, when printing, this resolution refers to the physical printer's resolution. The logical DPI on the other hand, refers to the resolution used by the actual paint engine.

  Note that if the `physicalDpiY()` doesn't equal the `logicalDpiY()`, the corresponding `QPaintEngine` must handle the resolution mapping.

See also:
  `physicalDpiX()`, and `logicalDpiY()`.

  Specified by:
    `physicalDpiY` in interface `QPaintDeviceInterface`

### release

    public final boolean release()

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

### size

    public final QSize size()

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

### texture

    public final int texture()

  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.

### toImage

    public final QImage toImage()

  Returns the contents of this framebuffer object as a `QImage`.

### width

    public final int width()

  Returns the width of the paint device in default coordinate system units (e. . pixels for `QPixmap` and `QWidget`).

See also:
  `widthMM()`.

  Specified by:
    `width` in interface `QPaintDeviceInterface`

### widthMM

    public final int widthMM()

  Returns the width of the paint device in millimeters.

See also:
  `width()`.

  Specified by:
    `widthMM` in interface `QPaintDeviceInterface`

### metric

    public int metric(QPaintDevice.PaintDeviceMetric metric)

  Returns the metric information for the given paint device `metric`.

See also:
  `PaintDeviceMetric` .

  Specified by:
    `metric` in interface `QPaintDeviceInterface`

### paintEngine

    public QPaintEngine paintEngine()

  Returns a pointer to the paint engine used for drawing on the device.

  Specified by:
    `paintEngine` in interface `QPaintDeviceInterface`

### hasOpenGLFramebufferObjects

    public static boolean hasOpenGLFramebufferObjects()

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

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD