The QGLFormat class specifies the display format of an OpenGL rendering context. More...
#include <qgl.h>
Inherits QGL.
A display format has several characteristics:
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 like alpha channel or stereographic viewing. If you request some features the driver/hardware does not provide when you create a QGLWidget, you will get the a rendering context with the nearest subset of features.
There are different ways of defining the display characteristics of a rendering context. One is to create a QGLFormat and make it default for the entire application:
QGLFormat f; f.setAlpha( TRUE ); f.setStereo( TRUE ); QGLFormat::setDefaultFormat( f );
Or you can specify the desired format when creating an object of your QGLWidget subclass:
QGLFormat f; f.setDoubleBuffer( FALSE ); // I want single buffer f.setDirectRendering( FALSE ); // I want software rendering MyGLWidget* myWidget = new MyGLWidget( f, ... );
After the widget has been created, you can test which of the requested features the system was able to provide:
QGLFormat f; f.setOverlay( TRUE ); f.setStereo( TRUE ); MyGLWidget* myWidget = new MyGLWidget( f, ... ); if ( !w->format().stereo() ) { // ok, goggles off if ( !w->format().hasOverlay() ) { qFatal( "Cool hardware wanted" ); } }
See also QGLContext and QGLWidget.
Constructs a QGLFormat object with the factory default settings:
Creates a QGLFormat object that is a copy of the current application default format.
If options is not 0, this copy will be modified by these format options. The options parameter must 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 MyGLWidget::MyGLWidget( QWidget* parent, const char* name ) : QGLWidget( QGLFormat( StencilBuffer | AlphaChannel ), parent, name ) { if ( !format().stencil() ) qWarning( "Could not get stencil buffer; results will be suboptimal" ); if ( !format().alphaChannel() ) qWarning( "Could not get alpha channel; results will be suboptimal" ); ... }
Note that there exists FormatOption values for both turning on and off all format settings, e.g. DepthBuffer and NoDepthBuffer, DirectRendering and IndirectRendering, etc.
See also defaultFormat() and setOption().
Returns TRUE if the accumulation buffer is enabled, otherwise FALSE. The accumulation buffer is disabled by default.
See also setAccum().
Returns TRUE if the alpha channel of the framebuffer is enabled, otherwise FALSE. The alpha channel is disabled by default.
See also setAlpha().
[static]
Returns the default QGLFormat for the application. All QGLWidgets that are created use this format unless anything else is specified.
If no special default format has been set using setDefaultFormat(), the default format is the same as that created with QGLFormat().
See also setDefaultFormat().
[static]
Returns the default QGLFormat for overlay contexts.
The factory default overlay format is:
See also setDefaultFormat().
Returns TRUE if the depth buffer is enabled, otherwise FALSE. The depth buffer is enabled by default.
See also setDepth().
Returns TRUE if direct rendering is enabled, otherwise FALSE.
Direct rendering is enabled by default.
See also setDirectRendering().
Returns TRUE if double buffering is enabled, otherwise FALSE. Double buffering is enabled by default.
See also setDoubleBuffer().
[static]
Returns TRUE if the window system has any OpenGL support, otherwise FALSE.
Note: This function may not be called until the QApplication object has been created.
[static]
Returns TRUE if the window system supports OpenGL overlays, otherwise FALSE.
Note: This function may not be called until the QApplication object has been created.
Returns TRUE if overlay plane is enabled, otherwise FALSE.
Overlay is disabled by default.
See also setOverlay().
Returns the plane of this format. Default for normal formats is 0, which means the normal plane; default for overlay formats is 1, which is the first overlay plane.
See also setPlane().
Returns TRUE if RGBA color mode is set, or FALSE if color index mode is set. The default color mode is RGBA.
See also setRgba().
Enables the accumulation buffer if enable is TRUE, or disables it if enable is FALSE.
The accumulation buffer is disabled by default.
The accumulation buffer is used for create blur effects and multiple exposures.
See also accum().
Enables the alpha channel of the framebuffer if enable is TRUE, or disables it if enable is FALSE.
The alpha buffer is disabled by default.
The alpha channel is typically used for implementing transparency or translucency. The A in RGBA specifies the transparency of a pixel.
See also alpha().
[static]
Sets a new default QGLFormat for the application. For example, to set single buffering as default instead of double buffering, your main() can contain:
QApplication a(argc, argv); QGLFormat f; f.setDoubleBuffer( FALSE ); QGLFormat::setDefaultFormat( f );
See also defaultFormat().
[static]
Sets a new default QGLFormat for overlay contexts. This format is used whenever a QGLWidget is created with a format with hasOverlay() enabled.
For example, to get a double buffered overlay contexts (if available), the code can do:
QGLFormat f = QGLFormat::defaultOverlayFormat(); f.setDoubleBuffer( TRUE ); QGLFormat::setDefaultOverlayFormat( f );
As usual, you can test after the widget creation whether the underlying OpenGL system was able to provide the requested specification:
// (...continued from above) MyGLWidget* myWidget = new MyGLWidget( QGLFormat( QGL::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 were available }
See also defaultOverlayFormat().
Enables the depth buffer if enable is TRUE, or disables it if enable is FALSE.
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.
See also depth().
Enables direct rendering if enable is TRUE, or disables it if enable is FALSE.
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.
See also directRendering().
Sets double buffering if enable is TRUE or single buffering if enable is FALSE.
Double buffering is enabled by default.
Double buffering is a technique where graphics is rendered to 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.
See also doubleBuffer(), QGLContext::swapBuffers() and QGLWidget::swapBuffers().
Sets the option opt.
See also testOption().
Enables an overlay plane if enable is TRUE; otherwise disables it.
Enabling the overlay plane will cause QGLWidget to create an additional context in an overlay plane. See the QGLWidget documentation for further information.
See also hasOverlay().
Sets the requested plane. 0 is the normal plane, 1 is the first overlay plane, 2 is the second overlay plane, etc., and -1, -2, etc. are underlay planes.
Note that, in contrast to the other format specifications, the plane specifications will be matched exactly. Thus, if you specify a plane that the underlying OpenGL system cannot provide, an invalid QGLWidget will be created.
See also plane().
Sets RGBA mode if enable is TRUE, or color index mode if enable is FALSE.
The default color mode is RGBA.
RGBA is the preferred mode for most OpenGL applications. In RGBA color mode you specify colors as a red + green + blue + alpha quadruplet.
In color index mode you specify an index into a color lookup table.
See also rgba().
Enables the stencil buffer if enable is TRUE, or disables it if enable is FALSE.
The stencil buffer is disabled by default.
The stencil buffer masks away drawing from certain parts of the screen.
See also stencil().
Enables stereo buffering if enable is TRUE, or disables it if enable is FALSE.
Stereo buffering is disabled by default.
Stereo buffering provides extra color buffers to generate left-eye and right-eye images.
See also stereo().
Returns TRUE if the stencil buffer is enabled, otherwise FALSE. The stencil buffer is disabled by default.
See also setStencil().
Returns TRUE if stereo buffering is enabled, otherwise FALSE. Stereo buffering is disabled by default.
See also setStereo().
Returns TRUE if format option opt is set, otherwise FALSE.
See also setOption().
Returns the version number string for the Qt OpenGL extension, e.g. "1.0".
Search the documentation, FAQ, qt-interest archive and more (uses
www.trolltech.com):
This file is part of the Qt toolkit, copyright © 1995-2000 Trolltech, all rights reserved.
Copyright © 2000 Trolltech | Trademarks | Qt version 2.2.1
|