QGLFormat(3qt)

πŸ“¦ version 3.3.8b, in fedora 43, fedora 44

πŸ’… QGLFormat(3qt) β€” the manual page, bestie edition πŸ’…

okay so. this is QGLFormat(3qt), and it's literally all about the display format of an OpenGL rendering context. we're doing part 1 of 2 so grab a snack, we're not done yet πŸ“


✨ NAME ✨

QGLFormat β€” the display format of an OpenGL rendering context. that's the whole vibe. she decides how your GL context is gonna look. πŸ‘‘


🌸 SYNOPSIS 🌸

#include <qgl.h>

Inherits QGL.

🫢 Public Members

QGLFormat ()
QGLFormat ( int options, int plane = 0 )
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 ( FormatOption opt )
bool testOption ( FormatOption opt ) const

πŸ’œ Static Public Members

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

πŸŽ€ DESCRIPTION πŸŽ€

The QGLFormat class specifies the display format of an OpenGL rendering context. she's the one holding the clipboard telling everyone what this context is allowed to be. πŸ’…

a display format has several characteristics, and yes, we're listing all of them, no skipping:

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

so you create a QGLFormat object and you tell it exactly which rendering options you want from an OpenGL<sup>*</sup> rendering context. manifesting, but for pixels. ✨

ngl, OpenGL drivers or accelerated hardware may or may not support the fancy stuff β€” alpha channel, stereographic viewing, all of that. if you request 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. so like, you get what you get, bestie. 😭

there are different ways to define the display characteristics of a rendering context. one way: create a QGLFormat and make it the default for the entire application:

QGLFormat f;
f.setAlpha( TRUE );
f.setStereo( TRUE );
QGLFormat::setDefaultFormat( f );

or you can specify the desired format right when you create an object of your QGLWidget subclass:

QGLFormat f;
f.setDoubleBuffer( FALSE );                 // single buffer
f.setDirectRendering( FALSE );              // software rendering
MyGLWidget* myWidget = new MyGLWidget( f, ... );

and after the widget has been created, you can find out which of the requested features the system was actually 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 required" );
    }
}

<sup>*</sup> OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other countries.

See also QGLContext, QGLWidget, Graphics Classes, and Image Processing Classes. πŸ‘€


πŸ’– MEMBER FUNCTION DOCUMENTATION πŸ’–

QGLFormat::QGLFormat ()

Constructs a QGLFormat object with the factory default settings, and here they are, all of them, no notes skipped:

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

QGLFormat::QGLFormat ( int 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 gets modified by those 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, 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 are FormatOption values to turn format settings both on and off, e.g. DepthBuffer and NoDepthBuffer, DirectRendering and IndirectRendering, etc. it's giving switches, not sliders. πŸ”₯

the plane parameter defaults to 0 and is the plane which this format should be associated with. not all OpenGL implementations support overlay/underlay rendering planes, so like... temper your expectations a lil. πŸ™ˆ

See also defaultFormat() and setOption().

bool QGLFormat::accum () const

Returns TRUE if the accumulation buffer is enabled; otherwise returns FALSE. the accumulation buffer is disabled by default.

See also setAccum().

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.

See also setAlpha().

QGLFormat QGLFormat::defaultFormat () [static]

Returns the default QGLFormat for the application. every single QGLWidget that gets created uses this format unless another format is specified, e.g. when they are constructed. she's the blueprint, the blueprint is her. πŸ‘‘

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

See also setDefaultFormat().

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

bool QGLFormat::depth () const

Returns TRUE if the depth buffer is enabled; otherwise returns FALSE. the depth buffer is enabled by default.

See also setDepth().

bool QGLFormat::directRendering () const

Returns TRUE if direct rendering is enabled; otherwise returns FALSE.

direct rendering is enabled by default.

See also setDirectRendering().

bool QGLFormat::doubleBuffer () const

Returns TRUE if double buffering is enabled; otherwise returns FALSE. double buffering is enabled by default.

See also setDoubleBuffer().

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. fr fr. do not test her early, she will not answer. πŸ’€

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. same rule, same energy. 😭

bool QGLFormat::hasOverlay () const

Returns TRUE if overlay plane is enabled; otherwise returns FALSE.

overlay is disabled by default.

See also setOverlay().

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

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.

See also setRgba().

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. motion blur girlies, this one's for you. 🌈

See also accum().

void QGLFormat::setAlpha ( bool enable )

if enable is TRUE enables the alpha channel; otherwise disables the alpha channel.

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. iconic behavior honestly. πŸ¦‹

See also alpha().

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:

QApplication a(argc, argv);
QGLFormat f;
f.setDoubleBuffer( FALSE );
QGLFormat::setDefaultFormat( f );

See also defaultFormat().

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:

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

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. so basically it's the bouncer at the club deciding who gets in and who stays hidden. πŸ’…

See also depth().

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. straight to the screen, no middleman, no detours. ✨

See also directRendering().

void QGLFormat::setDoubleBuffer ( bool enable )</p>

ok so bestie, if enable is TRUE this sets double buffering πŸ’– and if it's not, you get single buffering. simple as that.

Double buffering is on by default, no cap. 🫢

now lemme explain the vibe, because it's actually iconic: double buffering is a technique where graphics get rendered onto an off-screen buffer instead of straight to the screen. then, when the drawing's all done, the program calls a swapBuffers() function to swap the screen contents with that buffer. result? flicker-free drawing ✨ and often better performance. it's giving glow-up, honestly.

See also doubleBuffer(), QGLContext::swapBuffers(), and QGLWidget::swapBuffers().


void QGLFormat::setOption ( FormatOption opt )</p>

sets the format option to opt. that's the whole thing, she's low maintenance. πŸ’…

See also testOption().


void QGLFormat::setOverlay ( bool enable )</p>

if enable is TRUE, this enables an overlay plane 🌈; otherwise it disables the overlay plane. boom.

and heads up bestie, enabling the overlay plane will cause QGLWidget to create an additional context in an overlay plane. go read the QGLWidget documentation for the full tea. πŸ‘‘

See also hasOverlay().


void QGLFormat::setPlane ( int plane )</p>

sets the requested plane to plane. let's break it down:

  • 0 is the normal plane
  • 1 is the first overlay plane
  • 2 is the second overlay plane
  • etc.
  • -1, -2, etc. are underlay planes
⚠️ okay so here's the thing β€” in contrast to other format specifications, the plane specifications will be matched exactly. which means if you specify a plane that the underlying OpenGL system cannot provide, an invalid QGLWidget will be created. not a vibe. πŸ’€

See also plane().


void QGLFormat::setRgba ( bool enable )</p>

if enable is TRUE this sets RGBA mode 🎨. if enable is FALSE it sets color index mode. pick your fighter.

The default color mode is RGBA, periodt.

RGBA is the preferred mode for most OpenGL applications β€” in RGBA color mode you specify colors as red + green + blue + alpha quadruplets. cute, right? 🌸

in color index mode you specify an index into a color lookup table. retro energy, honestly.

See also rgba().


void QGLFormat::setStencil ( bool enable )</p>

if enable is TRUE this enables the stencil buffer; otherwise it disables the stencil buffer.

The stencil buffer is disabled by default. πŸ™ˆ

what does it even do? the stencil buffer masks certain parts of the drawing area so that masked parts are not drawn on. it's literally the bouncer at the club door of your canvas. πŸ’…

See also stencil().


void QGLFormat::setStereo ( bool enable )</p>

if enable is TRUE this enables stereo buffering; otherwise it disables stereo buffering.

Stereo buffering is disabled by default.

Stereo buffering provides extra color buffers to generate left-eye and right-eye images. πŸ‘€πŸ‘€ two eyes, two buffers, it's giving symmetry.

See also stereo().


bool QGLFormat::stencil () const</p>

returns TRUE if the stencil buffer is enabled; otherwise returns FALSE. and reminder bestie, the stencil buffer is disabled by default.

See also setStencil().


bool QGLFormat::stereo () const</p>

returns TRUE if stereo buffering is enabled; otherwise returns FALSE. Stereo buffering is disabled by default.

See also setStereo().


bool QGLFormat::testOption ( FormatOption opt ) const</p>

returns TRUE if format option opt is set; otherwise returns FALSE. vibe check for one specific option, love that for us. βœ…

See also setOption().


🌟 SEE ALSO 🌟


Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.


πŸŽ€ AUTHOR πŸŽ€

Generated automatically from the source code. (yes, the author is a robot. she doesn't miss. πŸ€–βœ¨)


πŸ¦‹ BUGS πŸ¦‹

If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. 🫢 fr fr, a good bug report is a love letter.

The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. (we're the niche audience and we're thriving πŸ’…)

If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qglformat.3qt) and the Qt version (3.3.8). don't be shy, include the deets bestie, it helps SO much.


ok that's the whole page!! this one came from the Trolltech AS girlies, dated 2 February 2007, and it's the man page for QGLFormat(3qt). go forth and format your OpenGL, my love πŸŒˆπŸ’– slay, periodt, no cap. 🧚⭐

πŸ“¦ where this page comes from