QGLFormat Class Reference

#include <qgl.h>

Inheritance diagram for QGLFormat:

Inheritance graph
[legend]
Collaboration diagram for QGLFormat:

Collaboration graph
[legend]
List of all members.

Detailed Description

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.

You can also specify preferred bit depths for the depth buffer, alpha buffer, accumulation buffer and the stencil buffer with the functions: 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 OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other countries. 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;
    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;
    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;
    fmt.setOverlay(true);
    fmt.setStereo(true);
    MyGLWidget* myWidget = new MyGLWidget(fmt, ...);
    if (!myWidget->format().stereo()) {
        // ok, goggles off
        if (!myWidget->format().hasOverlay()) {
            qFatal("Cool hardware required");
        }
    }

See also:
QGLContext, QGLWidget

Definition at line 107 of file qgl.h.

Public Types

enum  OpenGLVersionFlag

Public Member Functions

 QGLFormat ()
 QGLFormat (QGL::FormatOptions options, int plane=0)
 QGLFormat (const QGLFormat &other)
QGLFormatoperator= (const QGLFormat &other)
 ~QGLFormat ()
void setDepthBufferSize (int size)
int depthBufferSize () const
void setAccumBufferSize (int size)
int accumBufferSize () const
void setRedBufferSize (int size)
int redBufferSize () const
void setGreenBufferSize (int size)
int greenBufferSize () const
void setBlueBufferSize (int size)
int blueBufferSize () const
void setAlphaBufferSize (int size)
int alphaBufferSize () const
void setStencilBufferSize (int size)
int stencilBufferSize () const
void setSampleBuffers (bool enable)
bool sampleBuffers () const
void setSamples (int numSamples)
int samples () const
void setSwapInterval (int interval)
int swapInterval () const
bool doubleBuffer () const
void setDoubleBuffer (bool enable)
bool depth () const
void setDepth (bool enable)
bool rgba () const
void setRgba (bool enable)
bool alpha () const
void setAlpha (bool enable)
bool accum () const
void setAccum (bool enable)
bool stencil () const
void setStencil (bool enable)
bool stereo () const
void setStereo (bool enable)
bool directRendering () const
void setDirectRendering (bool enable)
bool hasOverlay () const
void setOverlay (bool enable)
int plane () const
void setPlane (int plane)
void setOption (QGL::FormatOptions opt)
bool testOption (QGL::FormatOptions opt) const

Static Public Member Functions

static QGLFormat defaultFormat ()
static void setDefaultFormat (const QGLFormat &f)
static QGLFormat defaultOverlayFormat ()
static void setDefaultOverlayFormat (const QGLFormat &f)
static bool hasOpenGL ()
static bool hasOpenGLOverlays ()
static OpenGLVersionFlags openGLVersionFlags ()

Private Attributes

QGLFormatPrivated

Friends

Q_OPENGL_EXPORT bool operator== (const QGLFormat &, const QGLFormat &)
Q_OPENGL_EXPORT bool operator!= (const QGLFormat &, const QGLFormat &)


Member Enumeration Documentation

enum QGLFormat::OpenGLVersionFlag

Since:
4.2
This enum describes the various OpenGL versions that are recognized by Qt. Use the QGLFormat::openGLVersionFlags() function to identify which versions that are supported at runtime.

OpenGL_Version_None If no OpenGL is present or if no OpenGL context is current.

OpenGL_Version_1_1 OpenGL version 1.1 or higher is present.

OpenGL_Version_1_2 OpenGL version 1.2 or higher is present.

OpenGL_Version_1_3 OpenGL version 1.3 or higher is present.

OpenGL_Version_1_4 OpenGL version 1.4 or higher is present.

OpenGL_Version_1_5 OpenGL version 1.5 or higher is present.

OpenGL_Version_2_0 OpenGL version 2.0 or higher is present. Note that version 2.0 supports all the functionality of version 1.5.

OpenGL_Version_2_1 OpenGL version 2.1 or higher is present.

OpenGL_ES_CommonLite_Version_1_0 OpenGL ES version 1.0 Common Lite or higher is present.

OpenGL_ES_Common_Version_1_0 OpenGL ES version 1.0 Common or higher is present. The Common profile supports all the features of Common Lite.

OpenGL_ES_CommonLite_Version_1_1 OpenGL ES version 1.1 Common Lite or higher is present.

OpenGL_ES_Common_Version_1_1 OpenGL ES version 1.1 Common or higher is present. The Common profile supports all the features of Common Lite.

OpenGL_ES_Version_2_0 OpenGL ES version 2.0 or higher is present. Note that OpenGL ES version 2.0 does not support all the features of OpenGL ES 1.x. So if OpenGL_ES_Version_2_0 is returned, none of the ES 1.x flags are returned.

See also {http://www.opengl.org} for more information about the different revisions of OpenGL.

See also:
openGLVersionFlags()

Definition at line 180 of file qgl.h.

00180                             {
00181         OpenGL_Version_None               = 0x00000000,
00182         OpenGL_Version_1_1                = 0x00000001,
00183         OpenGL_Version_1_2                = 0x00000002,
00184         OpenGL_Version_1_3                = 0x00000004,
00185         OpenGL_Version_1_4                = 0x00000008,
00186         OpenGL_Version_1_5                = 0x00000010,
00187         OpenGL_Version_2_0                = 0x00000020,
00188         OpenGL_Version_2_1                = 0x00000040,
00189         OpenGL_ES_Common_Version_1_0      = 0x00000080,
00190         OpenGL_ES_CommonLite_Version_1_0  = 0x00000100,
00191         OpenGL_ES_Common_Version_1_1      = 0x00000200,
00192         OpenGL_ES_CommonLite_Version_1_1  = 0x00000400,
00193         OpenGL_ES_Version_2_0             = 0x00000800
00194     };


Constructor & Destructor Documentation

QGLFormat::QGLFormat (  ) 

Constructs a QGLFormat object with the factory default settings: 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.

Definition at line 269 of file qgl.cpp.

References d.

00270 {
00271     d = new QGLFormatPrivate;
00272 }

QGLFormat::QGLFormat ( QGL::FormatOptions  options,
int  plane = 0 
)

Creates a QGLFormat object that is a copy of the current 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
    MyGLWidget::MyGLWidget(QWidget* parent)
        : QGLWidget(QGLFormat(QGL::StencilBuffer | QGL::AlphaChannel), parent)
    {
        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 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.

See also:
defaultFormat(), setOption()

Definition at line 310 of file qgl.cpp.

References d, defaultFormat(), QGLFormatPrivate::opts, and QGLFormatPrivate::pln.

00311 {
00312     d = new QGLFormatPrivate;
00313     QGL::FormatOptions newOpts = options;
00314     d->opts = defaultFormat().d->opts;
00315     d->opts |= (newOpts & 0xffff);
00316     d->opts &= ~(newOpts >> 16);
00317     d->pln = plane;
00318 }

Here is the call graph for this function:

QGLFormat::QGLFormat ( const QGLFormat other  ) 

Constructs a copy of other.

Definition at line 324 of file qgl.cpp.

References d.

00325 {
00326     d = new QGLFormatPrivate;
00327     *d = *other.d;
00328 }

QGLFormat::~QGLFormat (  ) 

Destroys the QGLFormat.

Definition at line 343 of file qgl.cpp.

References d.

00344 {
00345     delete d;
00346 }


Member Function Documentation

QGLFormat & QGLFormat::operator= ( const QGLFormat other  ) 

Assigns other to this object.

Definition at line 334 of file qgl.cpp.

References d.

00335 {
00336     *d = *other.d;
00337     return *this;
00338 }

void QGLFormat::setDepthBufferSize ( int  size  ) 

Set the preferred depth buffer size to size.

See also:
depthBufferSize(), setDepth(), depth()

Definition at line 754 of file qgl.cpp.

References d, QGLFormatPrivate::depthSize, and qWarning().

00755 {
00756     if (size < 0) {
00757         qWarning("QGLFormat::setDepthBufferSize: Cannot set negative depth buffer size %d", size);
00758         return;
00759     }
00760     d->depthSize = size;
00761 }

Here is the call graph for this function:

int QGLFormat::depthBufferSize (  )  const

Returns the depth buffer size.

See also:
depth(), setDepth(), setDepthBufferSize()

Definition at line 768 of file qgl.cpp.

References d, and QGLFormatPrivate::depthSize.

Referenced by qt_format_to_attrib_list().

00769 {
00770    return d->depthSize;
00771 }

void QGLFormat::setAccumBufferSize ( int  size  ) 

Set the preferred accumulation buffer size, where size is the bit depth for each RGBA component.

See also:
accum(), setAccum(), accumBufferSize()

Definition at line 889 of file qgl.cpp.

References QGLFormatPrivate::accumSize, d, and qWarning().

00890 {
00891     if (size < 0) {
00892         qWarning("QGLFormat::setAccumBufferSize: Cannot set negative accumulate buffer size %d", size);
00893         return;
00894     }
00895     d->accumSize = size;
00896 }

Here is the call graph for this function:

int QGLFormat::accumBufferSize (  )  const

Returns the accumulation buffer size.

See also:
setAccumBufferSize(), accum(), setAccum()

Definition at line 903 of file qgl.cpp.

References QGLFormatPrivate::accumSize, and d.

Referenced by qt_format_to_attrib_list().

00904 {
00905    return d->accumSize;
00906 }

void QGLFormat::setRedBufferSize ( int  size  ) 

Since:
4.2
Set the preferred red buffer size to size.

See also:
setGreenBufferSize(), setBlueBufferSize(), setAlphaBufferSize()

Definition at line 780 of file qgl.cpp.

References d, qWarning(), and QGLFormatPrivate::redSize.

00781 {
00782     if (size < 0) {
00783         qWarning("QGLFormat::setRedBufferSize: Cannot set negative red buffer size %d", size);
00784         return;
00785     }
00786     d->redSize = size;
00787 }

Here is the call graph for this function:

int QGLFormat::redBufferSize (  )  const

Since:
4.2
Returns the red buffer size.

See also:
setRedBufferSize()

Definition at line 796 of file qgl.cpp.

References d, and QGLFormatPrivate::redSize.

Referenced by qt_format_to_attrib_list().

00797 {
00798    return d->redSize;
00799 }

void QGLFormat::setGreenBufferSize ( int  size  ) 

Since:
4.2
Set the preferred green buffer size to size.

See also:
setRedBufferSize(), setBlueBufferSize(), setAlphaBufferSize()

Definition at line 808 of file qgl.cpp.

References d, QGLFormatPrivate::greenSize, and qWarning().

00809 {
00810     if (size < 0) {
00811         qWarning("QGLFormat::setGreenBufferSize: Cannot set negative green buffer size %d", size);
00812         return;
00813     }
00814     d->greenSize = size;
00815 }

Here is the call graph for this function:

int QGLFormat::greenBufferSize (  )  const

Since:
4.2
Returns the green buffer size.

See also:
setGreenBufferSize()

Definition at line 824 of file qgl.cpp.

References d, and QGLFormatPrivate::greenSize.

Referenced by qt_format_to_attrib_list().

00825 {
00826    return d->greenSize;
00827 }

void QGLFormat::setBlueBufferSize ( int  size  ) 

Since:
4.2
Set the preferred blue buffer size to size.

See also:
setRedBufferSize(), setGreenBufferSize(), setAlphaBufferSize()

Definition at line 836 of file qgl.cpp.

References QGLFormatPrivate::blueSize, d, and qWarning().

00837 {
00838     if (size < 0) {
00839         qWarning("QGLFormat::setBlueBufferSize: Cannot set negative blue buffer size %d", size);
00840         return;
00841     }
00842     d->blueSize = size;
00843 }

Here is the call graph for this function:

int QGLFormat::blueBufferSize (  )  const

Since:
4.2
Returns the blue buffer size.

See also:
setBlueBufferSize()

Definition at line 852 of file qgl.cpp.

References QGLFormatPrivate::blueSize, and d.

Referenced by qt_format_to_attrib_list().

00853 {
00854    return d->blueSize;
00855 }

void QGLFormat::setAlphaBufferSize ( int  size  ) 

Set the preferred alpha buffer size to size. This function implicitly enables the alpha channel.

See also:
setRedBufferSize(), setGreenBufferSize(), alphaBufferSize()

Definition at line 863 of file qgl.cpp.

References QGL::AlphaChannel, QGLFormatPrivate::alphaSize, d, qWarning(), and setOption().

Referenced by ArthurFrame::ArthurFrame().

00864 {
00865     if (size < 0) {
00866         qWarning("QGLFormat::setAlphaBufferSize: Cannot set negative alpha buffer size %d", size);
00867         return;
00868     }
00869     d->alphaSize = size;
00870     setOption(QGL::AlphaChannel);
00871 }

Here is the call graph for this function:

int QGLFormat::alphaBufferSize (  )  const

Returns the alpha buffer size.

See also:
alpha(), setAlpha(), setAlphaBufferSize()

Definition at line 878 of file qgl.cpp.

References QGLFormatPrivate::alphaSize, and d.

Referenced by qt_format_to_attrib_list().

00879 {
00880    return d->alphaSize;
00881 }

void QGLFormat::setStencilBufferSize ( int  size  ) 

Set the preferred stencil buffer size to size.

See also:
stencilBufferSize(), setStencil(), stencil()

Definition at line 913 of file qgl.cpp.

References d, qWarning(), and QGLFormatPrivate::stencilSize.

00914 {
00915     if (size < 0) {
00916         qWarning("QGLFormat::setStencilBufferSize: Cannot set negative stencil buffer size %d", size);
00917         return;
00918     }
00919     d->stencilSize = size;
00920 }

Here is the call graph for this function:

int QGLFormat::stencilBufferSize (  )  const

Returns the stencil buffer size.

See also:
stencil(), setStencil(), setStencilBufferSize()

Definition at line 927 of file qgl.cpp.

References d, and QGLFormatPrivate::stencilSize.

Referenced by qt_format_to_attrib_list().

00928 {
00929    return d->stencilSize;
00930 }

void QGLFormat::setSampleBuffers ( bool  enable  ) 

If enable is true, a GL context with multisample buffer support is picked; otherwise ignored.

See also:
sampleBuffers(), setSamples(), samples()

Definition at line 595 of file qgl.cpp.

References QGL::NoSampleBuffers, QGL::SampleBuffers, and setOption().

Referenced by ArthurFrame::ArthurFrame(), and main().

00596 {
00597     setOption(enable ? QGL::SampleBuffers : QGL::NoSampleBuffers);
00598 }

Here is the call graph for this function:

bool QGLFormat::sampleBuffers (  )  const [inline]

Returns true if multisample buffer support is enabled; otherwise returns false.

The multisample buffer is disabled by default.

See also:
setSampleBuffers()

Definition at line 462 of file qgl.h.

References QGL::SampleBuffers, and testOption().

Referenced by main(), and qt_format_to_attrib_list().

00463 {
00464     return testOption(QGL::SampleBuffers);
00465 }

Here is the call graph for this function:

void QGLFormat::setSamples ( int  numSamples  ) 

Set the preferred number of samples per pixel when multisampling is enabled to numSamples. By default, the highest number of samples available is used.

See also:
setSampleBuffers(), sampleBuffers(), samples()

Definition at line 619 of file qgl.cpp.

References d, QGLFormatPrivate::numSamples, and qWarning().

00620 {
00621     if (numSamples < 0) {
00622         qWarning("QGLFormat::setSamples: Cannot have negative number of samples per pixel %d", numSamples);
00623         return;
00624     }
00625     d->numSamples = numSamples;
00626 }

Here is the call graph for this function:

int QGLFormat::samples (  )  const

Returns the number of samples per pixel when multisampling is enabled. By default, the highest number of samples that is available is used.

See also:
setSampleBuffers(), sampleBuffers(), setSamples()

Definition at line 607 of file qgl.cpp.

References d, and QGLFormatPrivate::numSamples.

Referenced by qt_format_to_attrib_list().

00608 {
00609    return d->numSamples;
00610 }

void QGLFormat::setSwapInterval ( int  interval  ) 

Since:
4.2
Set the preferred swap interval. This can be used to sync the GL drawing into a system window to the vertical refresh of the screen. Setting an interval value of 0 will turn the vertical refresh syncing off, any value higher than 0 will turn the vertical syncing on.

Under Windows, where the {WGL_EXT_swap_control} extension is 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.

Note that setting the swap interval is only supported under Windows and on Mac OS X. Under Windows the {WGL_EXT_swap_control} extension has to be present.

Definition at line 646 of file qgl.cpp.

References d, and QGLFormatPrivate::swapInterval.

00647 {
00648     d->swapInterval = interval;
00649 }

int QGLFormat::swapInterval (  )  const

Since:
4.2
Returns the currently set swap interval. -1 is returned if setting the swap interval isn't supported in the system GL implementation (e.g. under X11).

Definition at line 658 of file qgl.cpp.

References d, and QGLFormatPrivate::swapInterval.

00659 {
00660     return d->swapInterval;
00661 }

bool QGLFormat::doubleBuffer (  )  const [inline]

Returns true if double buffering is enabled; otherwise returns false. Double buffering is enabled by default.

See also:
setDoubleBuffer()

Definition at line 417 of file qgl.h.

References QGL::DoubleBuffer, and testOption().

Referenced by qt_format_to_attrib_list().

00418 {
00419     return testOption(QGL::DoubleBuffer);
00420 }

Here is the call graph for this function:

void QGLFormat::setDoubleBuffer ( bool  enable  ) 

If enable is true sets double buffering; otherwise sets single buffering.

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(), QGLContext::swapBuffers(), QGLWidget::swapBuffers()

Definition at line 373 of file qgl.cpp.

References QGL::DoubleBuffer, setOption(), and QGL::SingleBuffer.

Referenced by QGLWidget::renderPixmap().

00374 {
00375     setOption(enable ? QGL::DoubleBuffer : QGL::SingleBuffer);
00376 }

Here is the call graph for this function:

bool QGLFormat::depth (  )  const [inline]

Returns true if the depth buffer is enabled; otherwise returns false. The depth buffer is enabled by default.

See also:
setDepth(), setDepthBufferSize()

Definition at line 422 of file qgl.h.

References QGL::DepthBuffer, and testOption().

Referenced by qt_format_to_attrib_list().

00423 {
00424     return testOption(QGL::DepthBuffer);
00425 }

Here is the call graph for this function:

void QGLFormat::setDepth ( bool  enable  ) 

If enable is true enables the depth buffer; otherwise disables the depth buffer.

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(), setDepthBufferSize()

Definition at line 403 of file qgl.cpp.

References QGL::DepthBuffer, QGL::NoDepthBuffer, and setOption().

00404 {
00405     setOption(enable ? QGL::DepthBuffer : QGL::NoDepthBuffer);
00406 }

Here is the call graph for this function:

bool QGLFormat::rgba (  )  const [inline]

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()

Definition at line 427 of file qgl.h.

References QGL::Rgba, and testOption().

Referenced by QGLContext::chooseContext(), QGLWidget::qglClearColor(), and QGLWidget::qglColor().

00428 {
00429     return testOption(QGL::Rgba);
00430 }

Here is the call graph for this function:

void QGLFormat::setRgba ( bool  enable  ) 

If enable is true sets RGBA mode. If enable is false sets color index mode.

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()

Definition at line 434 of file qgl.cpp.

References QGL::ColorIndex, QGL::Rgba, and setOption().

00435 {
00436     setOption(enable ? QGL::Rgba : QGL::ColorIndex);
00437 }

Here is the call graph for this function:

bool QGLFormat::alpha (  )  const [inline]

Returns true if the alpha buffer in the framebuffer is enabled; otherwise returns false. The alpha buffer is disabled by default.

See also:
setAlpha(), setAlphaBufferSize()

Definition at line 432 of file qgl.h.

References QGL::AlphaChannel, and testOption().

Referenced by qt_format_to_attrib_list().

00433 {
00434     return testOption(QGL::AlphaChannel);
00435 }

Here is the call graph for this function:

void QGLFormat::setAlpha ( bool  enable  ) 

If enable is true enables the alpha buffer; otherwise disables the alpha buffer.

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.

See also:
alpha(), setAlphaBufferSize()

Definition at line 462 of file qgl.cpp.

References QGL::AlphaChannel, QGL::NoAlphaChannel, and setOption().

Referenced by ArthurFrame::ArthurFrame().

00463 {
00464     setOption(enable ? QGL::AlphaChannel : QGL::NoAlphaChannel);
00465 }

Here is the call graph for this function:

bool QGLFormat::accum (  )  const [inline]

Returns true if the accumulation buffer is enabled; otherwise returns false. The accumulation buffer is disabled by default.

See also:
setAccum(), setAccumBufferSize()

Definition at line 437 of file qgl.h.

References QGL::AccumBuffer, and testOption().

Referenced by qt_format_to_attrib_list().

00438 {
00439     return testOption(QGL::AccumBuffer);
00440 }

Here is the call graph for this function:

void QGLFormat::setAccum ( bool  enable  ) 

If enable is true enables the accumulation buffer; otherwise disables the accumulation buffer.

The accumulation buffer is disabled by default.

The accumulation buffer is used to create blur effects and multiple exposures.

See also:
accum(), setAccumBufferSize()

Definition at line 489 of file qgl.cpp.

References QGL::AccumBuffer, QGL::NoAccumBuffer, and setOption().

00490 {
00491     setOption(enable ? QGL::AccumBuffer : QGL::NoAccumBuffer);
00492 }

Here is the call graph for this function:

bool QGLFormat::stencil (  )  const [inline]

Returns true if the stencil buffer is enabled; otherwise returns false. The stencil buffer is disabled by default.

See also:
setStencil(), setStencilBufferSize()

Definition at line 442 of file qgl.h.

References QGL::StencilBuffer, and testOption().

Referenced by qt_format_to_attrib_list().

00443 {
00444     return testOption(QGL::StencilBuffer);
00445 }

Here is the call graph for this function:

void QGLFormat::setStencil ( bool  enable  ) 

If enable is true enables the stencil buffer; otherwise disables the stencil buffer.

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(), setStencilBufferSize()

Definition at line 516 of file qgl.cpp.

References QGL::NoStencilBuffer, setOption(), and QGL::StencilBuffer.

Referenced by ArthurFrame::ArthurFrame().

00517 {
00518     setOption(enable ? QGL::StencilBuffer: QGL::NoStencilBuffer);
00519 }

Here is the call graph for this function:

bool QGLFormat::stereo (  )  const [inline]

Returns true if stereo buffering is enabled; otherwise returns false. Stereo buffering is disabled by default.

See also:
setStereo()

Definition at line 447 of file qgl.h.

References QGL::StereoBuffers, and testOption().

Referenced by qt_format_to_attrib_list().

00448 {
00449     return testOption(QGL::StereoBuffers);
00450 }

Here is the call graph for this function:

void QGLFormat::setStereo ( bool  enable  ) 

If enable is true enables stereo buffering; otherwise disables stereo buffering.

Stereo buffering is disabled by default.

Stereo buffering provides extra color buffers to generate left-eye and right-eye images.

See also:
stereo()

Definition at line 543 of file qgl.cpp.

References QGL::NoStereoBuffers, setOption(), and QGL::StereoBuffers.

00544 {
00545     setOption(enable ? QGL::StereoBuffers : QGL::NoStereoBuffers);
00546 }

Here is the call graph for this function:

bool QGLFormat::directRendering (  )  const [inline]

Returns true if direct rendering is enabled; otherwise returns false.

Direct rendering is enabled by default.

See also:
setDirectRendering()

Definition at line 452 of file qgl.h.

References QGL::DirectRendering, and testOption().

Referenced by QGLContext::chooseContext().

00453 {
00454     return testOption(QGL::DirectRendering);
00455 }

Here is the call graph for this function:

void QGLFormat::setDirectRendering ( bool  enable  ) 

If enable is true enables direct rendering; otherwise disables direct rendering.

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()

Definition at line 573 of file qgl.cpp.

References QGL::DirectRendering, QGL::IndirectRendering, and setOption().

Referenced by QGLWidget::renderPixmap().

00574 {
00575     setOption(enable ? QGL::DirectRendering : QGL::IndirectRendering);
00576 }

Here is the call graph for this function:

bool QGLFormat::hasOverlay (  )  const [inline]

Returns true if overlay plane is enabled; otherwise returns false.

Overlay is disabled by default.

See also:
setOverlay()

Definition at line 457 of file qgl.h.

References QGL::HasOverlay, and testOption().

Referenced by QGLWidgetPrivate::init().

00458 {
00459     return testOption(QGL::HasOverlay);
00460 }

Here is the call graph for this function:

void QGLFormat::setOverlay ( bool  enable  ) 

If enable is true enables an overlay plane; otherwise disables the overlay plane.

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()

Definition at line 684 of file qgl.cpp.

References QGL::HasOverlay, QGL::NoOverlay, and setOption().

Referenced by setDefaultOverlayFormat().

00685 {
00686     setOption(enable ? QGL::HasOverlay : QGL::NoOverlay);
00687 }

Here is the call graph for this function:

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.

See also:
setPlane()

Definition at line 696 of file qgl.cpp.

References d, and QGLFormatPrivate::pln.

00697 {
00698     return d->pln;
00699 }

void QGLFormat::setPlane ( int  plane  ) 

Sets the requested plane to plane. 0 is the normal plane, 1 is the first overlay plane, 2 is the second overlay plane, etc.; -1, -2, etc. are underlay planes.

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.

See also:
plane()

Definition at line 714 of file qgl.cpp.

References d, and QGLFormatPrivate::pln.

00715 {
00716     d->pln = plane;
00717 }

void QGLFormat::setOption ( QGL::FormatOptions  opt  ) 

Sets the format option to opt.

See also:
testOption()

Definition at line 725 of file qgl.cpp.

References d, and QGLFormatPrivate::opts.

Referenced by setAccum(), setAlpha(), setAlphaBufferSize(), setDepth(), setDirectRendering(), setDoubleBuffer(), setOverlay(), setRgba(), setSampleBuffers(), setStencil(), and setStereo().

00726 {
00727     if (opt & 0xffff)
00728         d->opts |= opt;
00729     else
00730        d->opts &= ~(opt >> 16);
00731 }

bool QGLFormat::testOption ( QGL::FormatOptions  opt  )  const

Returns true if format option opt is set; otherwise returns false.

See also:
setOption()

Definition at line 741 of file qgl.cpp.

References d, and QGLFormatPrivate::opts.

Referenced by accum(), alpha(), depth(), directRendering(), doubleBuffer(), hasOverlay(), rgba(), sampleBuffers(), stencil(), and stereo().

00742 {
00743     if (opt & 0xffff)
00744        return (d->opts & opt) != 0;
00745     else
00746        return (d->opts & (opt >> 16)) == 0;
00747 }

QGLFormat QGLFormat::defaultFormat (  )  [static]

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.

If no special default format has been set using setDefaultFormat(), the default format is the same as that created with QGLFormat().

See also:
setDefaultFormat()

Definition at line 1118 of file qgl.cpp.

Referenced by ArthurFrame::ArthurFrame(), QGLPixelBuffer::hasOpenGLPbuffers(), QGLExtensions::init_extensions(), QGLWidgetPrivate::initContext(), main(), CompositionRenderer::paint(), QGLFormat(), QGLWidget::QGLWidget(), and setDefaultOverlayFormat().

01119 {
01120     return *qgl_default_format();
01121 }

void QGLFormat::setDefaultFormat ( const QGLFormat f  )  [static]

Sets a new default QGLFormat for the application to f. For example, to set single buffering as the default instead of double buffering, your main() might contain code like this:

See also:
defaultFormat()

Definition at line 1137 of file qgl.cpp.

Referenced by ArthurFrame::ArthurFrame(), and main().

01138 {
01139     *qgl_default_format() = f;
01140 }

QGLFormat QGLFormat::defaultOverlayFormat (  )  [static]

Returns the default QGLFormat for overlay contexts.

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).

See also:
setDefaultFormat()

Definition at line 1163 of file qgl.cpp.

Referenced by QGLWidgetPrivate::init().

01164 {
01165     return *QGLDefaultOverlayFormat::instance();
01166 }

void QGLFormat::setDefaultOverlayFormat ( const QGLFormat f  )  [static]

Sets a new default QGLFormat for overlay contexts to f. This format is used whenever a QGLWidget is created with a format that hasOverlay() enabled.

For example, to get a double buffered overlay context (if available), use code like this:

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(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 are available
    }

See also:
defaultOverlayFormat()

Definition at line 1202 of file qgl.cpp.

References defaultFormat(), and setOverlay().

01203 {
01204     QGLFormat *defaultFormat = QGLDefaultOverlayFormat::instance();
01205     *defaultFormat = f;
01206     // Make sure the user doesn't request that the overlays themselves
01207     // have overlays, since it is unlikely that the system supports
01208     // infinitely many planes...
01209     defaultFormat->setOverlay(false);
01210 }

Here is the call graph for this function:

bool QGLFormat::hasOpenGL (  )  [static]

Returns true if the window system has any OpenGL support; otherwise returns false.

Warning:
This function must not be called until the QApplication object has been created.

Definition at line 273 of file qgl_x11.cpp.

References X11.

Referenced by CompositionWidget::CompositionWidget(), GradientWidget::GradientWidget(), main(), openGLVersionFlags(), PathDeformWidget::PathDeformWidget(), PathStrokeWidget::PathStrokeWidget(), View::View(), and XFormWidget::XFormWidget().

00274 {
00275     return glXQueryExtension(X11->display, 0, 0) != 0;
00276 }

bool QGLFormat::hasOpenGLOverlays (  )  [static]

Returns true if the window system supports OpenGL overlays; otherwise returns false.

Warning:
This function must not be called until the QApplication object has been created.

Definition at line 279 of file qgl_x11.cpp.

References find_trans_colors(), and trans_colors.

00280 {
00281     if (!trans_colors_init)
00282         find_trans_colors();
00283     return trans_colors.size() > 0;
00284 }

Here is the call graph for this function:

QGLFormat::OpenGLVersionFlags QGLFormat::openGLVersionFlags (  )  [static]

Since:
4.2
Identifies, at runtime, which OpenGL versions that are supported by the current platform.

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 texting) 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.

See also:
hasOpenGL(), hasOpenGLOverlays()

Definition at line 1084 of file qgl.cpp.

References hasOpenGL(), OpenGL_Version_None, and qOpenGLVersionFlagsFromString().

01085 {
01086     static bool firstTime=true;
01087     static OpenGLVersionFlags versionFlags = OpenGL_Version_None;
01088 
01089     if (!firstTime)
01090         return versionFlags;
01091 
01092     if (!hasOpenGL())
01093         return OpenGL_Version_None;
01094 
01095     if (firstTime) {
01096         firstTime = false;
01097 
01098         QString versionString(reinterpret_cast<const char*>(glGetString(GL_VERSION)));
01099         versionFlags = qOpenGLVersionFlagsFromString(versionString);
01100     }
01101 
01102     return versionFlags;
01103 }

Here is the call graph for this function:


Friends And Related Function Documentation

Q_OPENGL_EXPORT bool operator== ( const QGLFormat ,
const QGLFormat  
) [friend]

Returns true if all the options of the two QGLFormats are equal; otherwise returns false.

Definition at line 1218 of file qgl.cpp.

01219 {
01220     return (int) a.d->opts == (int) b.d->opts && a.d->pln == b.d->pln && a.d->alphaSize == b.d->alphaSize
01221         && a.d->accumSize == b.d->accumSize && a.d->stencilSize == b.d->stencilSize
01222         && a.d->depthSize == b.d->depthSize;
01223 }

Q_OPENGL_EXPORT bool operator!= ( const QGLFormat ,
const QGLFormat  
) [friend]

Returns false if all the options of the two QGLFormats are equal; otherwise returns true.

Definition at line 1231 of file qgl.cpp.

01232 {
01233     return !(a == b);
01234 }


Member Data Documentation

QGLFormatPrivate* QGLFormat::d [private]

Definition at line 200 of file qgl.h.

Referenced by accumBufferSize(), alphaBufferSize(), blueBufferSize(), depthBufferSize(), greenBufferSize(), operator=(), plane(), QGLFormat(), redBufferSize(), samples(), setAccumBufferSize(), setAlphaBufferSize(), setBlueBufferSize(), setDepthBufferSize(), setGreenBufferSize(), setOption(), setPlane(), setRedBufferSize(), setSamples(), setStencilBufferSize(), setSwapInterval(), stencilBufferSize(), swapInterval(), testOption(), and ~QGLFormat().


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 17:45:34 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1