|
|||||||||
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:
QImage
using toImage()
. This is normally much faster than calling QGLWidget::renderPixmap()
.OpenGL
texture using updateDynamicTexture()
. This allows us to create dynamic textures and works on all systems with pbuffer support.OpenGL
texture. The texture is then updated automatically when the pbuffer contents change, eliminating the need for additional copy operations. This is supported only on Windows and Mac OS X systems that provide the render_texture extension.OpenGL
pbuffer extension; call hasOpenGLPbuffer()
to find out if the system provides pbuffers.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9 |
Constructor Summary | |
---|---|
QGLPixelBuffer(int width,
int height)
Constructs an OpenGL pbuffer with the width and height. |
|
QGLPixelBuffer(int width,
int height,
QGLFormat format)
Constructs an OpenGL pbuffer with the width and height. |
|
QGLPixelBuffer(int width,
int height,
QGLFormat format,
QGLWidget shareWidget)
Constructs an OpenGL pbuffer with the width and height. |
|
QGLPixelBuffer(QSize size)
Constructs an OpenGL pbuffer of the given size. |
|
QGLPixelBuffer(QSize size,
QGLFormat format)
Constructs an OpenGL pbuffer of the given size. |
|
QGLPixelBuffer(QSize size,
QGLFormat format,
QGLWidget shareWidget)
Constructs an OpenGL pbuffer of the given size. |
Method Summary | |
---|---|
int |
bindTexture(QImage image)
Generates and binds a 2D GL texture to the current context, based on image. |
int |
bindTexture(QImage image,
int target)
Generates and binds a 2D GL texture to the current context, based on image. |
int |
bindTexture(QPixmap pixmap)
Generates and binds a 2D GL texture based on pixmap. |
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_id 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. |
boolean |
doneCurrent()
Makes no context the current OpenGL context. |
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. |
QGLFormat |
format()
Returns the format of the pbuffer. |
static QGLPixelBuffer |
fromNativePointer(QNativePointer 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. |
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. |
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. |
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 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 |
---|
public QGLPixelBuffer(QSize size, QGLFormat format)
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).
size()
, and format()
.
public QGLPixelBuffer(QSize size)
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).
size()
, and format()
.
public QGLPixelBuffer(QSize size, QGLFormat format, QGLWidget shareWidget)
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).
size()
, and format()
.
public QGLPixelBuffer(int width, int height, QGLFormat format)
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).
size()
, and format()
.
public QGLPixelBuffer(int width, int height)
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).
size()
, and format()
.
public QGLPixelBuffer(int width, int height, QGLFormat format, QGLWidget shareWidget)
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).
size()
, and format()
.
Method Detail |
---|
public final int bindTexture(QImage image)
glBindTexture()
calls. The target parameter specifies the texture target.
Equivalent to calling QGLContext::bindTexture()
.
deleteTexture()
.
public final int bindTexture(QImage image, int target)
glBindTexture()
calls. The target parameter specifies the texture target.
Equivalent to calling QGLContext::bindTexture()
.
deleteTexture()
.
public final int bindTexture(QPixmap pixmap)
Equivalent to calling QGLContext::bindTexture()
.
deleteTexture()
.
public final int bindTexture(QPixmap pixmap, int target)
Equivalent to calling QGLContext::bindTexture()
.
deleteTexture()
.
public final int bindTexture(java.lang.String fileName)
Equivalent to calling QGLContext::bindTexture()
.
deleteTexture()
.
public final boolean bindToDynamicTexture(int texture)
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 = new QGLPixelBuffer(256, 256); //... pbuffer.makeCurrent(); int 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.
generateDynamicTexture()
, and releaseFromDynamicTexture()
.
public final void deleteTexture(int texture_id)
Equivalent to calling QGLContext::deleteTexture()
.
public final int depth()
depth
in interface QPaintDeviceInterface
public final boolean doneCurrent()
OpenGL
context. Returns true on success; otherwise returns false.
public final void drawTexture(QPointF point, int textureId)
Equivalent to the corresponding QGLContext::drawTexture()
.
public final void drawTexture(QPointF point, int textureId, int textureTarget)
Equivalent to the corresponding QGLContext::drawTexture()
.
public final void drawTexture(QRectF target, int textureId)
OpenGL
model space. The textureTarget should be a 2D texture target. Equivalent to the corresponding QGLContext::drawTexture()
.
public final void drawTexture(QRectF target, int textureId, int textureTarget)
OpenGL
model space. The textureTarget should be a 2D texture target. Equivalent to the corresponding QGLContext::drawTexture()
.
public final QGLFormat format()
public final int generateDynamicTexture()
bindToDynamicTexture()
and updateDynamicTexture()
. size()
.
public final long handle()
public final int height()
QPixmap
and QWidget
). heightMM()
.
height
in interface QPaintDeviceInterface
public final int heightMM()
height()
.
heightMM
in interface QPaintDeviceInterface
public final boolean isValid()
public final int logicalDpiX()
widthMM()
. Note that if the logicalDpiX()
doesn't equal the physicalDpiX()
, the corresponding QPaintEngine
must handle the resolution mapping.
logicalDpiY()
, and physicalDpiX()
.
logicalDpiX
in interface QPaintDeviceInterface
public final int logicalDpiY()
heightMM()
. Note that if the logicalDpiY()
doesn't equal the physicalDpiY()
, the corresponding QPaintEngine
must handle the resolution mapping.
logicalDpiX()
, and physicalDpiY()
.
logicalDpiY
in interface QPaintDeviceInterface
public final boolean makeCurrent()
OpenGL
rendering context. Returns true on success; otherwise returns false. QGLContext::makeCurrent()
, and doneCurrent()
.
public final int numColors()
INT_MAX
is returned instead.
numColors
in interface QPaintDeviceInterface
public final boolean paintingActive()
QPainter::begin()
but not yet called QPainter::end()
for this device; otherwise returns false. QPainter::isActive()
.
paintingActive
in interface QPaintDeviceInterface
public final int physicalDpiX()
Note that if the physicalDpiX()
doesn't equal the logicalDpiX()
, the corresponding QPaintEngine
must handle the resolution mapping.
physicalDpiY()
, and logicalDpiX()
.
physicalDpiX
in interface QPaintDeviceInterface
public final int physicalDpiY()
Note that if the physicalDpiY()
doesn't equal the logicalDpiY()
, the corresponding QPaintEngine
must handle the resolution mapping.
physicalDpiX()
, and logicalDpiY()
.
physicalDpiY
in interface QPaintDeviceInterface
public final void releaseFromDynamicTexture()
bindToDynamicTexture()
.
public final QSize size()
public final QImage toImage()
QImage
.
public final void updateDynamicTexture(int texture_id)
The texture must be of the same size and format as the pbuffer.
Example:
QGLPixelBuffer pbuffer = new QGLPixelBuffer(256, 256); // ... pbuffer.makeCurrent(); int 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. generateDynamicTexture()
, and bindToDynamicTexture()
.
public final int width()
QPixmap
and QWidget
). widthMM()
.
width
in interface QPaintDeviceInterface
public final int widthMM()
width()
.
widthMM
in interface QPaintDeviceInterface
public int metric(QPaintDevice.PaintDeviceMetric metric)
PaintDeviceMetric
.
metric
in interface QPaintDeviceInterface
public QPaintEngine paintEngine()
paintEngine
in interface QPaintDeviceInterface
public static boolean hasOpenGLPbuffers()
OpenGL
pbuffer extension is present on this system; otherwise returns false.
public static QGLPixelBuffer fromNativePointer(QNativePointer nativePointer)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |