.BI "void \fBsetDefaultFormat\fR ( const QGLFormat & f )"
.br
.ti -1c
.BI "QGLFormat \fBdefaultOverlayFormat\fR ()"
.br
.ti -1c
.BI "void \fBsetDefaultOverlayFormat\fR ( const QGLFormat & f )"
.br
.ti -1c
.BI "bool \fBhasOpenGL\fR ()"
.br
.ti -1c
.BI "bool \fBhasOpenGLOverlays\fR ()"
.br
.in -1c
.SH DESCRIPTION
The QGLFormat class specifies the display format of an OpenGL rendering context.
.PP
A display format has several characteristics:
.TP
Double or single buffering.
.TP
Depth buffer.
.TP
RGBA or color index mode.
.TP
Alpha channel.
.TP
Accumulation buffer.
.TP
Stencil buffer.
.TP
Stereo buffers.
.TP
Direct rendering.
.TP
Presence of an overlay.
.TP
The plane of an overlay format.
.PP
You create and tell a QGLFormat object what rendering options you want from an OpenGL<sup>*</sup> rendering context.
.PP
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.
.PP
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:
.PP
.nf
.br
QGLFormat f;
.br
f.setAlpha( TRUE );
.br
f.setStereo( TRUE );
.br
QGLFormat::setDefaultFormat( f );
.br
.fi
.PP
Or you can specify the desired format when creating an object of your QGLWidget subclass:
Note that there are FormatOption values to turn format settings both on and off, e.g. DepthBuffer and NoDepthBuffer, DirectRendering and IndirectRendering, etc.
.PP
The \fIplane\fR parameter defaults to 0 and is the plane which this format should be associated with. Not all OpenGL implmentations supports overlay/underlay rendering planes.
.PP
See also defaultFormat() and setOption().
.SH "bool QGLFormat::accum () const"
Returns TRUE if the accumulation buffer is enabled; otherwise returns FALSE. The accumulation buffer is disabled by default.
.PP
See also setAccum().
.SH "bool QGLFormat::alpha () const"
Returns TRUE if the alpha channel of the framebuffer is enabled; otherwise returns FALSE. The alpha channel is disabled by default.
Returns the default QGLFormat for the application. All QGLWidgets that are created use this format unless another format is specified, e.g. when they are constructed.
.PP
If no special default format has been set using setDefaultFormat(), the default format is the same as that created with QGLFormat().
Returns TRUE if the window system supports OpenGL overlays; otherwise returns FALSE.
.PP
\fBWarning:\fR This function must not be called until the QApplication object has been created.
.SH "bool QGLFormat::hasOverlay () const"
Returns TRUE if overlay plane is enabled; otherwise returns FALSE.
.PP
Overlay is disabled by default.
.PP
See also setOverlay().
.SH "int QGLFormat::plane () const"
Returns the plane of this format. The default for normal formats is 0, which means the normal plane. The default for overlay formats is 1, which is the first overlay plane.
.PP
See also setPlane().
.SH "bool QGLFormat::rgba () const"
Returns TRUE if RGBA color mode is set. Returns FALSE if color index mode is set. The default color mode is RGBA.
.PP
See also setRgba().
.SH "void QGLFormat::setAccum ( bool enable )"
If \fIenable\fR is TRUE enables the accumulation buffer; otherwise disables the accumulation buffer.
.PP
The accumulation buffer is disabled by default.
.PP
The accumulation buffer is used to create blur effects and multiple exposures.
.PP
See also accum().
.SH "void QGLFormat::setAlpha ( bool enable )"
If \fIenable\fR is TRUE enables the alpha channel; otherwise disables the alpha channel.
.PP
The alpha buffer is disabled by default.
.PP
The alpha channel is typically used for implementing transparency or translucency. The A in RGBA specifies the transparency of a pixel.
.PP
See also alpha().
.SH "void QGLFormat::setDefaultFormat ( const QGLFormat & f )\fC [static]\fR"
Sets a new default QGLFormat for the application to \fIf\fR. For example, to set single buffering as the default instead of double buffering, your main() might contain code like this:
.PP
.nf
.br
QApplication a(argc, argv);
.br
QGLFormat f;
.br
f.setDoubleBuffer( FALSE );
.br
QGLFormat::setDefaultFormat( f );
.br
.fi
.PP
See also defaultFormat().
.SH "void QGLFormat::setDefaultOverlayFormat ( const QGLFormat & f )\fC [static]\fR"
Sets a new default QGLFormat for overlay contexts to \fIf\fR. This format is used whenever a QGLWidget is created with a format that hasOverlay() enabled.
.PP
For example, to get a double buffered overlay context (if available), use code like this:
.PP
.nf
.br
QGLFormat f = QGLFormat::defaultOverlayFormat();
.br
f.setDoubleBuffer( TRUE );
.br
QGLFormat::setDefaultOverlayFormat( f );
.br
.fi
.PP
As usual, you can find out after widget creation whether the underlying OpenGL system was able to provide the requested specification:
.PP
.nf
.br
// ...continued from above
.br
MyGLWidget* myWidget = new MyGLWidget( QGLFormat( QGL::HasOverlay ), ... );
.br
if ( myWidget->format().hasOverlay() ) {
.br
// Yes, we got an overlay, let's check _its_ format:
; // no, only single buffered overlays are available
.br
}
.br
.fi
.PP
See also defaultOverlayFormat().
.SH "void QGLFormat::setDepth ( bool enable )"
If \fIenable\fR is TRUE enables the depth buffer; otherwise disables the depth buffer.
.PP
The depth buffer is enabled by default.
.PP
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.
If \fIenable\fR is TRUE enables direct rendering; otherwise disables direct rendering.
.PP
Direct rendering is enabled by default.
.PP
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.
If \fIenable\fR is TRUE sets double buffering; otherwise sets single buffering.
.PP
Double buffering is enabled by default.
.PP
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.
.PP
See also doubleBuffer(), QGLContext::swapBuffers(), and QGLWidget::swapBuffers().
If \fIenable\fR is TRUE enables an overlay plane; otherwise disables the overlay plane.
.PP
Enabling the overlay plane will cause QGLWidget to create an additional context in an overlay plane. See the QGLWidget documentation for further information.
.PP
See also hasOverlay().
.SH "void QGLFormat::setPlane ( int plane )"
Sets the requested plane to \fIplane\fR. 0 is the normal plane, 1 is the first overlay plane, 2 is the second overlay plane, etc.; -1, -2, etc. are underlay planes.
.PP
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.
.PP
See also plane().
.SH "void QGLFormat::setRgba ( bool enable )"
If \fIenable\fR is TRUE sets RGBA mode. If \fIenable\fR is FALSE sets color index mode.
.PP
The default color mode is RGBA.
.PP
RGBA is the preferred mode for most OpenGL applications. In RGBA color mode you specify colors as red + green + blue + alpha quadruplets.
.PP
In color index mode you specify an index into a color lookup table.
.PP
See also rgba().
.SH "void QGLFormat::setStencil ( bool enable )"
If \fIenable\fR is TRUE enables the stencil buffer; otherwise disables the stencil buffer.
.PP
The stencil buffer is disabled by default.
.PP
The stencil buffer masks certain parts of the drawing area so that masked parts are not drawn on.
.PP
See also stencil().
.SH "void QGLFormat::setStereo ( bool enable )"
If \fIenable\fR is TRUE enables stereo buffering; otherwise disables stereo buffering.
.PP
Stereo buffering is disabled by default.
.PP
Stereo buffering provides extra color buffers to generate left-eye and right-eye images.
.PP
See also stereo().
.SH "bool QGLFormat::stencil () const"
Returns TRUE if the stencil buffer is enabled; otherwise returns FALSE. The stencil buffer is disabled by default.
.PP
See also setStencil().
.SH "bool QGLFormat::stereo () const"
Returns TRUE if stereo buffering is enabled; otherwise returns FALSE. Stereo buffering is disabled by default.