|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.opengl.QGLFormat
public class QGLFormat
The QGLFormat class specifies the display format of an OpenGL rendering context. A display format has several characteristics:
Double or single buffering.
Depth buffer.
RGBA or color index mode.
Alpha channel.
Accumulation buffer.
Stencil buffer.
Stereo buffers.
Direct rendering.
Presence of an overlay.
The plane of an overlay format.
Multisample buffers.
setDepthBufferSize()
, setAlphaBufferSize()
, setAccumBufferSize()
and setStencilBufferSize()
. Note that even if you specify that you prefer a 32 bit depth buffer (e.g. with setDepthBufferSize(32)), the format that is chosen may not have a 32 bit depth buffer, even if there is a format available with a 32 bit depth buffer. The main reason for this is how the system dependant picking algorithms work on the different platforms, and some format options may have higher precedence than others.
You create and tell a QGLFormat object what rendering options you want from an OpenGL rendering context.
OpenGL drivers or accelerated hardware may or may not support advanced features such as alpha channel or stereographic viewing. If you request some features that the driver/hardware does not provide when you create a QGLWidget
, you will get a rendering context with the nearest subset of features.
There are different ways to define the display characteristics of a rendering context. One is to create a QGLFormat and make it the default for the entire application:
QGLFormat fmt = new QGLFormat(); fmt.setAlpha(true); fmt.setStereo(true); QGLFormat.setDefaultFormat(fmt);Or you can specify the desired format when creating an object of your
QGLWidget
subclass: QGLFormat fmt = new QGLFormat(); fmt.setDoubleBuffer(false); // single buffer fmt.setDirectRendering(false); // software rendering MyGLWidget myWidget = new MyGLWidget(fmt);After the widget has been created, you can find out which of the requested features the system was able to provide:
QGLFormat fmt = new QGLFormat(); fmt.setOverlay(true); fmt.setStereo(true); MyGLWidget myWidget = new MyGLWidget(fmt); if (!myWidget.format().stereo()) { // ok, goggles off if (!myWidget.format().hasOverlay()) { throw new RuntimeException("Cool hardware required"); } }OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other countries.
QGLContext
, and QGLWidget
.
Nested Class Summary | |
---|---|
static class |
QGLFormat.OpenGLVersionFlag
This enum describes the various OpenGL versions that are recognized by Qt. |
static class |
QGLFormat.OpenGLVersionFlags
|
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 | |
---|---|
QGLFormat()
Constructs a QGLFormat object with the factory default settings. |
|
QGLFormat(QGL.FormatOptions options)
Creates a QGLFormat object that is a copy of the current application default format . |
|
QGLFormat(QGL.FormatOptions options,
int plane)
Creates a QGLFormat object that is a copy of the current application default format . |
|
QGLFormat(QGLFormat other)
Constructs a copy of other. |
Method Summary | |
---|---|
boolean |
accum()
Returns true if the accumulation buffer is enabled; otherwise returns false. |
int |
accumBufferSize()
Returns the accumulation buffer size. |
boolean |
alpha()
Returns true if the alpha buffer in the framebuffer is enabled; otherwise returns false. |
int |
alphaBufferSize()
Returns the alpha buffer size. |
int |
blueBufferSize()
Returns the blue buffer size. |
QGLFormat |
clone()
This method is reimplemented for internal reasons |
static QGLFormat |
defaultFormat()
Returns the default QGLFormat for the application. |
static QGLFormat |
defaultOverlayFormat()
Returns the default QGLFormat for overlay contexts. |
boolean |
depth()
Returns true if the depth buffer is enabled; otherwise returns false. |
int |
depthBufferSize()
Returns the depth buffer size. |
boolean |
directRendering()
Returns true if direct rendering is enabled; otherwise returns false. |
boolean |
doubleBuffer()
Returns true if double buffering is enabled; otherwise returns false. |
int |
greenBufferSize()
Returns the green buffer size. |
static boolean |
hasOpenGL()
Returns true if the window system has any OpenGL support; otherwise returns false. |
static boolean |
hasOpenGLOverlays()
Returns true if the window system supports OpenGL overlays; otherwise returns false. |
boolean |
hasOverlay()
Returns true if overlay plane is enabled; otherwise returns false. |
static QGLFormat.OpenGLVersionFlags |
openGLVersionFlags()
Identifies, at runtime, which OpenGL versions that are supported by the current platform. |
int |
plane()
Returns the plane of this format. |
int |
redBufferSize()
Returns the red buffer size. |
boolean |
rgba()
Returns true if RGBA color mode is set. |
boolean |
sampleBuffers()
Returns true if multisample buffer support is enabled; otherwise returns false. |
int |
samples()
Returns the number of samples per pixel when multisampling is enabled. |
void |
setAccum(boolean enable)
If enable is true enables the accumulation buffer; otherwise disables the accumulation buffer. |
void |
setAccumBufferSize(int size)
Set the preferred accumulation buffer size, where size is the bit depth for each RGBA component. |
void |
setAlpha(boolean enable)
If enable is true enables the alpha buffer; otherwise disables the alpha buffer. |
void |
setAlphaBufferSize(int size)
Set the preferred alpha buffer size to size. |
void |
setBlueBufferSize(int size)
Set the preferred blue buffer size to size. |
static void |
setDefaultFormat(QGLFormat f)
Sets a new default QGLFormat for the application to f. |
static void |
setDefaultOverlayFormat(QGLFormat f)
Sets a new default QGLFormat for overlay contexts to f. |
void |
setDepth(boolean enable)
If enable is true enables the depth buffer; otherwise disables the depth buffer. |
void |
setDepthBufferSize(int size)
Set the minimum depth buffer size to size. |
void |
setDirectRendering(boolean enable)
If enable is true enables direct rendering; otherwise disables direct rendering. |
void |
setDoubleBuffer(boolean enable)
If enable is true sets double buffering; otherwise sets single buffering. |
void |
setGreenBufferSize(int size)
Set the preferred green buffer size to size. |
void |
setOption(QGL.FormatOption[] opt)
|
void |
setOption(QGL.FormatOptions opt)
Sets the format option to opt. |
void |
setOverlay(boolean enable)
If enable is true enables an overlay plane; otherwise disables the overlay plane. |
void |
setPlane(int plane)
Sets the requested plane to plane. |
void |
setRedBufferSize(int size)
Set the preferred red buffer size to size. |
void |
setRgba(boolean enable)
If enable is true sets RGBA mode. |
void |
setSampleBuffers(boolean enable)
If enable is true, a GL context with multisample buffer support is picked; otherwise ignored. |
void |
setSamples(int numSamples)
Set the preferred number of samples per pixel when multisampling is enabled to numSamples. |
void |
setStencil(boolean enable)
If enable is true enables the stencil buffer; otherwise disables the stencil buffer. |
void |
setStencilBufferSize(int size)
Set the preferred stencil buffer size to size. |
void |
setStereo(boolean enable)
If enable is true enables stereo buffering; otherwise disables stereo buffering. |
void |
setSwapInterval(int interval)
Set the preferred swap interval. |
boolean |
stencil()
Returns true if the stencil buffer is enabled; otherwise returns false. |
int |
stencilBufferSize()
Returns the stencil buffer size. |
boolean |
stereo()
Returns true if stereo buffering is enabled; otherwise returns false. |
int |
swapInterval()
Returns the currently set swap interval. |
boolean |
testOption(QGL.FormatOption[] opt)
|
boolean |
testOption(QGL.FormatOptions opt)
Returns true if format option opt is set; otherwise returns false. |
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 |
---|
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Constructor Detail |
---|
public QGLFormat()
Double buffer:
Enabled.Depth buffer:
Enabled.RGBA:
Enabled (i.e., color index disabled).Alpha channel:
Disabled.Accumulator buffer:
Disabled.Stencil buffer:
Disabled.Stereo:
Disabled.Direct rendering:
Enabled.Overlay:
Disabled.Plane:
0 (i.e., normal plane).Multisample buffers:
Disabled.
public QGLFormat(QGL.FormatOptions options)
application default format
. If options is not 0, this copy is modified by these format options. The options parameter should be FormatOption values OR'ed together.
This constructor makes it easy to specify a certain desired format in classes derived from QGLWidget
, for example:
// The rendering in MyGLWidget depends on using // stencil buffer and alpha channel class MyGLWidget extends QGLWidget { public MyGLWidget(QWidget parent) { super(new QGLFormat(new QGL.FormatOptions(QGL.FormatOption.StencilBuffer, QGL.FormatOption.AlphaChannel)), parent); if (!format().stencil()) System.err.println("Could not get stencil buffer; results will be suboptimal"); if (!format().alpha()) System.err.println("Could not get alpha channel; results will be suboptimal"); // ... } }Note that there are FormatOption values to turn format settings both on and off, e.g. DepthBuffer and NoDepthBuffer, DirectRendering and IndirectRendering, etc.
The plane parameter defaults to 0 and is the plane which this format should be associated with. Not all OpenGL implementations supports overlay/underlay rendering planes.
defaultFormat()
, and setOption()
.
public QGLFormat(QGL.FormatOptions options, int plane)
application default format
. If options is not 0, this copy is modified by these format options. The options parameter should be FormatOption values OR'ed together.
This constructor makes it easy to specify a certain desired format in classes derived from QGLWidget
, for example:
// The rendering in MyGLWidget depends on using // stencil buffer and alpha channel class MyGLWidget extends QGLWidget { public MyGLWidget(QWidget parent) { super(new QGLFormat(new QGL.FormatOptions(QGL.FormatOption.StencilBuffer, QGL.FormatOption.AlphaChannel)), parent); if (!format().stencil()) System.err.println("Could not get stencil buffer; results will be suboptimal"); if (!format().alpha()) System.err.println("Could not get alpha channel; results will be suboptimal"); // ... } }Note that there are FormatOption values to turn format settings both on and off, e.g. DepthBuffer and NoDepthBuffer, DirectRendering and IndirectRendering, etc.
The plane parameter defaults to 0 and is the plane which this format should be associated with. Not all OpenGL implementations supports overlay/underlay rendering planes.
defaultFormat()
, and setOption()
.
public QGLFormat(QGLFormat other)
Method Detail |
---|
public final boolean accum()
setAccum()
, and setAccumBufferSize()
.
public final int accumBufferSize()
setAccumBufferSize()
, accum()
, and setAccum()
.
public final boolean alpha()
setAlpha()
, and setAlphaBufferSize()
.
public final int alphaBufferSize()
alpha()
, setAlpha()
, and setAlphaBufferSize()
.
public final int blueBufferSize()
setBlueBufferSize()
.
public final boolean depth()
setDepth()
, and setDepthBufferSize()
.
public final int depthBufferSize()
depth()
, setDepth()
, and setDepthBufferSize()
.
public final boolean directRendering()
Direct rendering is enabled by default.
setDirectRendering()
.
public final boolean doubleBuffer()
setDoubleBuffer()
.
public final int greenBufferSize()
setGreenBufferSize()
.
public final boolean hasOverlay()
Overlay is disabled by default.
setOverlay()
.
public final int plane()
setPlane()
.
public final int redBufferSize()
setRedBufferSize()
.
public final boolean rgba()
setRgba()
.
public final boolean sampleBuffers()
The multisample buffer is disabled by default.
setSampleBuffers()
.
public final int samples()
setSampleBuffers()
, sampleBuffers()
, and setSamples()
.
public final void setAccum(boolean enable)
The accumulation buffer is disabled by default.
The accumulation buffer is used to create blur effects and multiple exposures.
accum()
, and setAccumBufferSize()
.
public final void setAccumBufferSize(int size)
accum()
, setAccum()
, and accumBufferSize()
.
public final void setAlpha(boolean enable)
The alpha buffer is disabled by default.
The alpha buffer is typically used for implementing transparency or translucency. The A in RGBA specifies the transparency of a pixel.
alpha()
, and setAlphaBufferSize()
.
public final void setAlphaBufferSize(int size)
setRedBufferSize()
, setGreenBufferSize()
, and alphaBufferSize()
.
public final void setBlueBufferSize(int size)
blueBufferSize()
, setRedBufferSize()
, setGreenBufferSize()
, and setAlphaBufferSize()
.
public final void setDepth(boolean enable)
The depth buffer is enabled by default.
The purpose of a depth buffer (or Z-buffering) is to remove hidden surfaces. Pixels are assigned Z values based on the distance to the viewer. A pixel with a high Z value is closer to the viewer than a pixel with a low Z value. This information is used to decide whether to draw a pixel or not.
depth()
, and setDepthBufferSize()
.
public final void setDepthBufferSize(int size)
depthBufferSize()
, setDepth()
, and depth()
.
public final void setDirectRendering(boolean enable)
Direct rendering is enabled by default.
Enabling this option will make OpenGL bypass the underlying window system and render directly from hardware to the screen, if this is supported by the system.
directRendering()
.
public final void setDoubleBuffer(boolean enable)
Double buffering is enabled by default.
Double buffering is a technique where graphics are rendered on an off-screen buffer and not directly to the screen. When the drawing has been completed, the program calls a swapBuffers() function to exchange the screen contents with the buffer. The result is flicker-free drawing and often better performance.
doubleBuffer()
, QGLContext::swapBuffers()
, and QGLWidget::swapBuffers()
.
public final void setGreenBufferSize(int size)
greenBufferSize()
, setRedBufferSize()
, setBlueBufferSize()
, and setAlphaBufferSize()
.
public final void setOption(QGL.FormatOption[] opt)
public final void setOption(QGL.FormatOptions opt)
testOption()
.
public final void setOverlay(boolean enable)
Enabling the overlay plane will cause QGLWidget
to create an additional context in an overlay plane. See the QGLWidget
documentation for further information.
hasOverlay()
.
public final void setPlane(int plane)
Note that in contrast to other format specifications, the plane specifications will be matched exactly. This means that if you specify a plane that the underlying OpenGL system cannot provide, an invalid
QGLWidget
will be created.
plane()
.
public final void setRedBufferSize(int size)
redBufferSize()
, setGreenBufferSize()
, setBlueBufferSize()
, and setAlphaBufferSize()
.
public final void setRgba(boolean enable)
The default color mode is RGBA.
RGBA is the preferred mode for most OpenGL applications. In RGBA color mode you specify colors as red + green + blue + alpha quadruplets.
In color index mode you specify an index into a color lookup table.
rgba()
.
public final void setSampleBuffers(boolean enable)
sampleBuffers()
, setSamples()
, and samples()
.
public final void setSamples(int numSamples)
setSampleBuffers()
, sampleBuffers()
, and samples()
.
public final void setStencil(boolean enable)
The stencil buffer is disabled by default.
The stencil buffer masks certain parts of the drawing area so that masked parts are not drawn on.
stencil()
, and setStencilBufferSize()
.
public final void setStencilBufferSize(int size)
stencilBufferSize()
, setStencil()
, and stencil()
.
public final void setStereo(boolean enable)
Stereo buffering is disabled by default.
Stereo buffering provides extra color buffers to generate left-eye and right-eye images.
stereo()
.
public final void setSwapInterval(int interval)
Under Windows and under X11, where the WGL_EXT_swap_control and GLX_SGI_video_sync extensions are used, the interval parameter can be used to set the minimum number of video frames that are displayed before a buffer swap will occur. In effect, setting the interval to 10, means there will be 10 vertical retraces between every buffer swap.
Under Windows the WGL_EXT_swap_control extension has to be present, and under X11 the GLX_SGI_video_sync extension has to be present.
swapInterval()
.
public final boolean stencil()
setStencil()
, and setStencilBufferSize()
.
public final int stencilBufferSize()
stencil()
, setStencil()
, and setStencilBufferSize()
.
public final boolean stereo()
setStereo()
.
public final int swapInterval()
setSwapInterval()
.
public final boolean testOption(QGL.FormatOption[] opt)
public final boolean testOption(QGL.FormatOptions opt)
setOption()
.
public static QGLFormat defaultFormat()
If no special default format has been set using setDefaultFormat()
, the default format is the same as that created with QGLFormat().
setDefaultFormat()
.
public static QGLFormat defaultOverlayFormat()
The factory default overlay format is:
Double buffer:
Disabled.Depth buffer:
Disabled.RGBA:
Disabled (i.e., color index enabled).Alpha channel:
Disabled.Accumulator buffer:
Disabled.Stencil buffer:
Disabled.Stereo:
Disabled.Direct rendering:
Enabled.Overlay:
Disabled.Plane:
1 (i.e., first overlay plane).setDefaultOverlayFormat()
, and setDefaultFormat()
.
public static boolean hasOpenGL()
Warning: This function must not be called until the QApplication
object has been created.
public static boolean hasOpenGLOverlays()
Warning: This function must not be called until the QApplication
object has been created.
public static QGLFormat.OpenGLVersionFlags openGLVersionFlags()
Note that if OpenGL version 1.5 is supported, its predecessors (i.e., version 1.4 and lower) are also supported. To identify the support of a particular feature, like multi texturing, test for the version in which the feature was first introduced (i.e., version 1.3 in the case of multi texturing) to adapt to the largest possible group of runtime platforms.
This function needs a valid current OpenGL context to work; otherwise it will return OpenGL_Version_None
.
hasOpenGL()
, and hasOpenGLOverlays()
.
public static void setDefaultFormat(QGLFormat f)
QApplication.initialize(args); QGLFormat f = new QGLFormat(); f.setDoubleBuffer(false); QGLFormat.setDefaultFormat(f);
defaultFormat()
.
public static void setDefaultOverlayFormat(QGLFormat f)
QGLWidget
is created with a format that hasOverlay()
enabled. For example, to get a double buffered overlay context (if available), use code like this:
QGLFormat f = QGLFormat.defaultOverlayFormat(); f.setDoubleBuffer(true); QGLFormat.setDefaultOverlayFormat(f);As usual, you can find out after widget creation whether the underlying OpenGL system was able to provide the requested specification:
// ...continued from above MyGLWidget myWidget = new MyGLWidget(new QGLFormat(new QGL.FormatOptions(QGL.FormatOption.HasOverlay))); if (myWidget.format().hasOverlay()) { // Yes, we got an overlay, let's check _its_ format: QGLContext olContext = myWidget.overlayContext(); if (olContext.format().doubleBuffer()) ; // yes, we got a double buffered overlay else ; // no, only single buffered overlays are available }
defaultOverlayFormat()
.
public QGLFormat clone()
clone
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |