|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.opengl.QGLPixelBuffer
public class QGLPixelBuffer
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:
Pbuffers are provided by the OpenGL pbuffer extension; call hasOpenGLPbuffer() to find out if the system provides pbuffers.
Example
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I> |
Constructor Summary | |
---|---|
QGLPixelBuffer(int width,
int height)
Equivalent to QGLPixelBuffer(width, height, QGLFormat::defaultFormat(), 0). |
|
QGLPixelBuffer(int width,
int height,
QGLFormat format)
Equivalent to QGLPixelBuffer(width, height, format, 0). |
|
QGLPixelBuffer(int width,
int height,
QGLFormat format,
QGLWidget shareWidget)
Constructs an OpenGL pbuffer with the width and height. |
|
QGLPixelBuffer(QSize size)
Equivalent to QGLPixelBuffer(size, QGLFormat::defaultFormat(), 0). |
|
QGLPixelBuffer(QSize size,
QGLFormat format)
Equivalent to QGLPixelBuffer(size, format, 0). |
|
QGLPixelBuffer(QSize size,
QGLFormat format,
QGLWidget shareWidget)
Constructs an OpenGL pbuffer of the given size. |
Method Summary | |
---|---|
int |
bindTexture(QImage image)
Equivalent to bindTexture(image, GL_TEXTURE_2D). |
int |
bindTexture(QImage image,
int target)
Generates and binds a 2D GL texture to the current context, based on image. |
int |
bindTexture(QPixmap pixmap)
Equivalent to bindTexture(pixmap, GL_TEXTURE_2D). |
int |
bindTexture(QPixmap pixmap,
int target)
Generates and binds a 2D GL texture based on pixmap. |
int |
bindTexture(java.lang.String fileName)
Reads the DirectDrawSurface (DDS) compressed file fileName and generates a 2D GL texture from it. |
boolean |
bindToDynamicTexture(int texture)
Binds the texture specified by texture to this pbuffer. |
void |
deleteTexture(int texture_id)
Removes the texture identified by texture_id from the texture cache. |
int |
depth()
Returns the bit depth (number of bit planes) of the paint device. |
int |
devType()
|
boolean |
doneCurrent()
Makes no context the current OpenGL context. |
QGLFormat |
format()
Returns the format of the pbuffer. |
static QGLPixelBuffer |
fromNativePointer(QNativePointer nativePointer)
This function returns the QGLPixelBuffer instance pointed to by nativePointer |
int |
generateDynamicTexture()
Generates and binds a 2D GL texture that is the same size as the pbuffer, and returns the texture's ID. |
long |
handle()
Returns the native pbuffer handle. |
static boolean |
hasOpenGLPbuffers()
Returns true if the OpenGL pbuffer extension is present on this system; otherwise returns false. |
int |
height()
Returns the height of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget). |
int |
heightMM()
Returns the height of the paint device in millimeters. |
boolean |
isValid()
Returns true if this pbuffer is valid; otherwise returns false. |
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. |
boolean |
makeCurrent()
Makes this pbuffer the current OpenGL rendering context. |
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.e. someone has called QPainter::begin() but not yet called QPainter::end() for this device; otherwise returns false. |
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. |
void |
releaseFromDynamicTexture()
Releases the pbuffer from any previously bound texture. |
QSize |
size()
Returns the size of the pbuffer. |
QImage |
toImage()
Returns the contents of the pbuffer as a QImage. |
void |
updateDynamicTexture(int texture_id)
Copies the pbuffer contents into the texture specified with texture_id. |
int |
width()
Returns the width of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget). |
int |
widthMM()
Returns the width of the paint device in millimeters. |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Constructor Detail |
---|
public QGLPixelBuffer(QSize size, QGLFormat format)
Equivalent to QGLPixelBuffer(size, format, 0).
public QGLPixelBuffer(QSize size)
Equivalent to QGLPixelBuffer(size, QGLFormat::defaultFormat(), 0).
public QGLPixelBuffer(QSize size, QGLFormat format, QGLWidget shareWidget)
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).
public QGLPixelBuffer(int width, int height, QGLFormat format)
Equivalent to QGLPixelBuffer(width, height, format, 0).
public QGLPixelBuffer(int width, int height)
Equivalent to QGLPixelBuffer(width, height, QGLFormat::defaultFormat(), 0).
public QGLPixelBuffer(int width, int height, QGLFormat format, QGLWidget shareWidget)
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).
Method Detail |
---|
public final int bindTexture(java.lang.String fileName)
Reads the DirectDrawSurface (DDS) compressed file fileName and generates a 2D GL texture from it.
Equivalent to calling QGLContext::bindTexture().
public final int bindTexture(QImage image)
Equivalent to bindTexture(image, GL_TEXTURE_2D).
public final int bindTexture(QImage image, int target)
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().
public final int bindTexture(QPixmap pixmap)
Equivalent to bindTexture(pixmap, GL_TEXTURE_2D).
public final int bindTexture(QPixmap pixmap, int target)
Generates and binds a 2D GL texture based on pixmap.
Equivalent to calling QGLContext::bindTexture().
public final boolean bindToDynamicTexture(int texture)
Binds the texture specified by texture 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.
public final void deleteTexture(int texture_id)
Removes the texture identified by texture_id from the texture cache.
Equivalent to calling QGLContext::deleteTexture().
public final int depth()
Returns the bit depth (number of bit planes) of the paint device.
depth
in interface QPaintDeviceInterface
public final boolean doneCurrent()
Makes no context the current OpenGL context. Returns true on success; otherwise returns false.
public final QGLFormat format()
Returns the format of the pbuffer. The format may be different from the one that was requested.
public final int generateDynamicTexture()
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.
public final long handle()
Returns the native pbuffer handle.
public final int height()
Returns the height of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget).
height
in interface QPaintDeviceInterface
public final int heightMM()
Returns the height of the paint device in millimeters.
heightMM
in interface QPaintDeviceInterface
public final boolean isValid()
Returns true if this pbuffer is valid; otherwise returns false.
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, but it varies on Windows.
Note that if the logicalDpiX doesn't equal the physicalDpiX, the corresponding QPaintEngine must handle the resolution mapping.
logicalDpiX
in interface QPaintDeviceInterface
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, but it varies on Windows.
Note that if the logicalDpiY doesn't equal the physicalDpiY, the corresponding QPaintEngine must handle the resolution mapping.
logicalDpiY
in interface QPaintDeviceInterface
public final boolean makeCurrent()
Makes this pbuffer the current OpenGL rendering context. Returns true on success; otherwise returns false.
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.
numColors
in interface QPaintDeviceInterface
public final boolean paintingActive()
Returns true if the device is currently being painted on, i.e. someone has called QPainter::begin() but not yet called QPainter::end() for this device; otherwise returns false.
paintingActive
in interface QPaintDeviceInterface
public final int physicalDpiX()
Returns the horizontal resolution of the device in dots per inch.
Note that if the physicalDpiX doesn't equal the logicalDpiX, the corresponding QPaintEngine must handle the resolution mapping.
physicalDpiX
in interface QPaintDeviceInterface
public final int physicalDpiY()
Returns the horizontal resolution of the device in dots per inch.
Note that if the physicalDpiY doesn't equal the logicalDpiY, the corresponding QPaintEngine must handle the resolution mapping.
physicalDpiY
in interface QPaintDeviceInterface
public final void releaseFromDynamicTexture()
Releases the pbuffer from any previously bound texture. Returns true on success; otherwise returns false.
public final QSize size()
Returns the size of the pbuffer.
public final QImage toImage()
Returns the contents of the pbuffer as a QImage.
public final void updateDynamicTexture(int texture_id)
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.
public final int width()
Returns the width of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget).
width
in interface QPaintDeviceInterface
public final int widthMM()
Returns the width of the paint device in millimeters.
widthMM
in interface QPaintDeviceInterface
public int devType()
devType
in interface QPaintDeviceInterface
public int metric(QPaintDevice.PaintDeviceMetric metric)
Returns the metric information for the given paint device metric.
metric
in interface QPaintDeviceInterface
public QPaintEngine paintEngine()
Returns a pointer to the paint engine used for drawing on the device.
paintEngine
in interface QPaintDeviceInterface
public static boolean hasOpenGLPbuffers()
Returns true if the OpenGL pbuffer extension is present on this system; otherwise returns false.
public static QGLPixelBuffer fromNativePointer(QNativePointer nativePointer)
nativePointer
- the QNativePointer of which object should be returned.
|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |