Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |
The TQGLFormat class specifies the display format of an OpenGL rendering context. More...
#include <tqgl.h>
Inherits TQGL.
A display format has several characteristics:
You create and tell a TQGLFormat 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 TQGLWidget, 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 TQGLFormat and make it the default for the entire application:
TQGLFormat f; f.setAlpha( TRUE ); f.setStereo( TRUE ); TQGLFormat::setDefaultFormat( f );
Or you can specify the desired format when creating an object of your TQGLWidget subclass:
TQGLFormat f; f.setDoubleBuffer( FALSE ); // single buffer f.setDirectRendering( FALSE ); // software rendering MyGLWidget* myWidget = new MyGLWidget( f, ... );
After the widget has been created, you can find out which of the requested features the system was able to provide:
TQGLFormat f; f.setOverlay( TRUE ); f.setStereo( TRUE ); MyGLWidget* myWidget = new MyGLWidget( f, ... ); if ( !w->format().stereo() ) { // ok, goggles off if ( !w->format().hasOverlay() ) { tqFatal( "Cool hardware required" ); } }
* OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other countries.
See also TQGLContext, TQGLWidget, Graphics Classes, and Image Processing Classes.
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 TQGLWidget, for example:
// The rendering in MyGLWidget depends on using // stencil buffer and alpha channel MyGLWidget::MyGLWidget( TQWidget* parent, const char* name ) : TQGLWidget( TQGLFormat( StencilBuffer | AlphaChannel ), parent, name ) { if ( !format().stencil() ) tqWarning( "Could not get stencil buffer; results will be suboptimal" ); if ( !format().alphaChannel() ) tqWarning( "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 implmentations supports overlay/underlay rendering planes.
See also defaultFormat() and setOption().
Returns TRUE if the accumulation buffer is enabled; otherwise returns FALSE. The accumulation buffer is disabled by default.
See also setAccum().
Returns TRUE if the alpha channel of the framebuffer is enabled; otherwise returns FALSE. The alpha channel is disabled by default.
See also setAlpha().
If no special default format has been set using setDefaultFormat(), the default format is the same as that created with TQGLFormat().
See also setDefaultFormat().
The factory default overlay format is:
See also setDefaultFormat().
Returns TRUE if the depth buffer is enabled; otherwise returns FALSE. The depth buffer is enabled by default.
See also setDepth().
Returns TRUE if direct rendering is enabled; otherwise returns FALSE.
Direct rendering is enabled by default.
See also setDirectRendering().
Returns TRUE if double buffering is enabled; otherwise returns FALSE. Double buffering is enabled by default.
See also setDoubleBuffer().
Returns TRUE if the window system has any OpenGL support; otherwise returns FALSE.
Warning: This function must not be called until the TQApplication object has been created.
Returns TRUE if the window system supports OpenGL overlays; otherwise returns FALSE.
Warning: This function must not be called until the TQApplication object has been created.
Returns TRUE if overlay plane is enabled; otherwise returns FALSE.
Overlay is disabled by default.
See also setOverlay().
See also setPlane().
Returns TRUE if RGBA color mode is set. Returns FALSE if color index mode is set. The default color mode is RGBA.
See also setRgba().
The accumulation buffer is disabled by default.
The accumulation buffer is used to create blur effects and multiple exposures.
See also accum().
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().
TQApplication a(argc, argv); TQGLFormat f; f.setDoubleBuffer( FALSE ); TQGLFormat::setDefaultFormat( f );
See also defaultFormat().
For example, to get a double buffered overlay context (if available), use code like this:
TQGLFormat f = TQGLFormat::defaultOverlayFormat(); f.setDoubleBuffer( TRUE ); TQGLFormat::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( TQGLFormat( TQGL::HasOverlay ), ... ); if ( myWidget->format().hasOverlay() ) { // Yes, we got an overlay, let's check _its_ format: TQGLContext* olContext = myWidget->overlayContext(); if ( olContext->format().doubleBuffer() ) ; // yes, we got a double buffered overlay else ; // no, only single buffered overlays are available }
See also defaultOverlayFormat().
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().
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().
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.
See also doubleBuffer(), TQGLContext::swapBuffers(), and TQGLWidget::swapBuffers().
See also testOption().
Enabling the overlay plane will cause TQGLWidget to create an additional context in an overlay plane. See the TQGLWidget documentation for further information.
See also hasOverlay().
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 TQGLWidget will be created.
See also plane().
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.
See also rgba().
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.
See also stencil().
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 returns FALSE. The stencil buffer is disabled by default.
See also setStencil().
Returns TRUE if stereo buffering is enabled; otherwise returns FALSE. Stereo buffering is disabled by default.
See also setStereo().
See also setOption().
This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.
Copyright © 2007 Trolltech | Trademarks | TQt 3.3.8
|