Qt 4.8
Public Types | Public Functions | Static Public Functions | Private Functions | Properties | Friends | List of all members
QGLFormat Class Reference

The QGLFormat class specifies the display format of an OpenGL rendering context. More...

#include <qgl.h>

Inheritance diagram for QGLFormat:
QGLDefaultOverlayFormat

Public Types

enum  OpenGLContextProfile { NoProfile, CoreProfile, CompatibilityProfile }
 This enum describes the OpenGL context profiles that can be specified for contexts implementing OpenGL version 3. More...
 
enum  OpenGLVersionFlag {
  OpenGL_Version_None = 0x00000000, OpenGL_Version_1_1 = 0x00000001, OpenGL_Version_1_2 = 0x00000002, OpenGL_Version_1_3 = 0x00000004,
  OpenGL_Version_1_4 = 0x00000008, OpenGL_Version_1_5 = 0x00000010, OpenGL_Version_2_0 = 0x00000020, OpenGL_Version_2_1 = 0x00000040,
  OpenGL_ES_Common_Version_1_0 = 0x00000080, OpenGL_ES_CommonLite_Version_1_0 = 0x00000100, OpenGL_ES_Common_Version_1_1 = 0x00000200, OpenGL_ES_CommonLite_Version_1_1 = 0x00000400,
  OpenGL_ES_Version_2_0 = 0x00000800, OpenGL_Version_3_0 = 0x00001000, OpenGL_Version_3_1 = 0x00002000, OpenGL_Version_3_2 = 0x00004000,
  OpenGL_Version_3_3 = 0x00008000, OpenGL_Version_4_0 = 0x00010000
}
 This enum describes the various OpenGL versions that are recognized by Qt. More...
 

Public Functions

bool accum () const
 Returns true if the accumulation buffer is enabled; otherwise returns false. More...
 
int accumBufferSize () const
 Returns the accumulation buffer size. More...
 
bool alpha () const
 Returns true if the alpha buffer in the framebuffer is enabled; otherwise returns false. More...
 
int alphaBufferSize () const
 Returns the alpha buffer size. More...
 
int blueBufferSize () const
 Returns the blue buffer size. More...
 
bool depth () const
 Returns true if the depth buffer is enabled; otherwise returns false. More...
 
int depthBufferSize () const
 Returns the depth buffer size. More...
 
bool directRendering () const
 Returns true if direct rendering is enabled; otherwise returns false. More...
 
bool doubleBuffer () const
 Returns true if double buffering is enabled; otherwise returns false. More...
 
int greenBufferSize () const
 Returns the green buffer size. More...
 
bool hasOverlay () const
 Returns true if overlay plane is enabled; otherwise returns false. More...
 
int majorVersion () const
 Returns the OpenGL major version. More...
 
int minorVersion () const
 Returns the OpenGL minor version. More...
 
QGLFormatoperator= (const QGLFormat &other)
 Assigns other to this object. More...
 
int plane () const
 Returns the plane of this format. More...
 
OpenGLContextProfile profile () const
 Returns the OpenGL context profile. More...
 
 QGLFormat ()
 Constructs a QGLFormat object with the following default settings: More...
 
 QGLFormat (QGL::FormatOptions options, int plane=0)
 Creates a QGLFormat object that is a copy of the current defaultFormat(). More...
 
 QGLFormat (const QGLFormat &other)
 Constructs a copy of other. More...
 
int redBufferSize () const
 Returns the red buffer size. More...
 
bool rgba () const
 Returns true if RGBA color mode is set. More...
 
bool sampleBuffers () const
 Returns true if multisample buffer support is enabled; otherwise returns false. More...
 
int samples () const
 Returns the number of samples per pixel when multisampling is enabled. More...
 
void setAccum (bool enable)
 If enable is true enables the accumulation buffer; otherwise disables the accumulation buffer. More...
 
void setAccumBufferSize (int size)
 Set the preferred accumulation buffer size, where size is the bit depth for each RGBA component. More...
 
void setAlpha (bool enable)
 If enable is true enables the alpha buffer; otherwise disables the alpha buffer. More...
 
void setAlphaBufferSize (int size)
 Set the preferred alpha buffer size to size. More...
 
void setBlueBufferSize (int size)
 Set the preferred blue buffer size to size. More...
 
void setDepth (bool enable)
 If enable is true enables the depth buffer; otherwise disables the depth buffer. More...
 
void setDepthBufferSize (int size)
 Set the minimum depth buffer size to size. More...
 
void setDirectRendering (bool enable)
 If enable is true enables direct rendering; otherwise disables direct rendering. More...
 
void setDoubleBuffer (bool enable)
 If enable is true sets double buffering; otherwise sets single buffering. More...
 
void setGreenBufferSize (int size)
 Set the preferred green buffer size to size. More...
 
void setOption (QGL::FormatOptions opt)
 Sets the format option to opt. More...
 
void setOverlay (bool enable)
 If enable is true enables an overlay plane; otherwise disables the overlay plane. More...
 
void setPlane (int plane)
 Sets the requested plane to plane. More...
 
void setProfile (OpenGLContextProfile profile)
 Set the OpenGL context profile to profile. More...
 
void setRedBufferSize (int size)
 Set the preferred red buffer size to size. More...
 
void setRgba (bool enable)
 If enable is true sets RGBA mode. More...
 
void setSampleBuffers (bool enable)
 If enable is true, a GL context with multisample buffer support is picked; otherwise ignored. More...
 
void setSamples (int numSamples)
 Set the preferred number of samples per pixel when multisampling is enabled to numSamples. More...
 
void setStencil (bool enable)
 If enable is true enables the stencil buffer; otherwise disables the stencil buffer. More...
 
void setStencilBufferSize (int size)
 Set the preferred stencil buffer size to size. More...
 
void setStereo (bool enable)
 If enable is true enables stereo buffering; otherwise disables stereo buffering. More...
 
void setSwapInterval (int interval)
 Set the preferred swap interval. More...
 
void setVersion (int major, int minor)
 Set the OpenGL version to the major and minor numbers. More...
 
bool stencil () const
 Returns true if the stencil buffer is enabled; otherwise returns false. More...
 
int stencilBufferSize () const
 Returns the stencil buffer size. More...
 
bool stereo () const
 Returns true if stereo buffering is enabled; otherwise returns false. More...
 
int swapInterval () const
 Returns the currently set swap interval. More...
 
bool testOption (QGL::FormatOptions opt) const
 Returns true if format option opt is set; otherwise returns false. More...
 
 ~QGLFormat ()
 Destroys the QGLFormat. More...
 

Static Public Functions

static QGLFormat defaultFormat ()
 
static QGLFormat defaultOverlayFormat ()
 Returns the default QGLFormat for overlay contexts. More...
 
static bool hasOpenGL ()
 Returns true if the window system has any OpenGL support; otherwise returns false. More...
 
static bool hasOpenGLOverlays ()
 Returns true if the window system supports OpenGL overlays; otherwise returns false. More...
 
static OpenGLVersionFlags openGLVersionFlags ()
 
static void setDefaultFormat (const QGLFormat &f)
 Sets a new default QGLFormat for the application to f. More...
 
static void setDefaultOverlayFormat (const QGLFormat &f)
 Sets a new default QGLFormat for overlay contexts to f. More...
 

Private Functions

void detach ()
 

Properties

QGLFormatPrivated
 

Friends

Q_OPENGL_EXPORT bool operator!= (const QGLFormat &, const QGLFormat &)
 Returns false if all the options of the two QGLFormat objects a and b are equal; otherwise returns true. More...
 
Q_OPENGL_EXPORT QDebug operator<< (QDebug, const QGLFormat &)
 
Q_OPENGL_EXPORT bool operator== (const QGLFormat &, const QGLFormat &)
 Returns true if all the options of the two QGLFormat objects a and b are equal; otherwise returns false. More...
 

Detailed Description

The QGLFormat class specifies the display format of an OpenGL rendering context.

A display format has several characteristics:

You can also specify preferred bit depths for the color buffer, depth buffer, alpha buffer, accumulation buffer and the stencil buffer with the functions: setRedBufferSize(), setGreenBufferSize(), setBlueBufferSize(), 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 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:

Or you can specify the desired format when creating an object of your QGLWidget subclass:

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:

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");
}
}

OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other countries.

See also
QGLContext, QGLWidget

Definition at line 175 of file qgl.h.

Enumerations

◆ OpenGLContextProfile

This enum describes the OpenGL context profiles that can be specified for contexts implementing OpenGL version 3.

Since
4.7

2 or higher. These profiles are different from OpenGL ES profiles.

  • NoProfile OpenGL version is lower than 3.2.
  • CoreProfile Functionality deprecated in OpenGL version 3.0 is not available.
  • CompatibilityProfile Functionality from earlier OpenGL versions is available.
Enumerator
NoProfile 
CoreProfile 
CompatibilityProfile 

Definition at line 252 of file qgl.h.

◆ OpenGLVersionFlag

This enum describes the various OpenGL versions that are recognized by Qt.

Since
4.2

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_Version_3_0 OpenGL version 3.0 or higher is present.
  • OpenGL_Version_3_1 OpenGL version 3.1 or higher is present. Note that OpenGL version 3.1 or higher does not necessarily support all the features of version 3.0 and lower.
  • OpenGL_Version_3_2 OpenGL version 3.2 or higher is present.
  • OpenGL_Version_3_3 OpenGL version 3.3 or higher is present.
  • OpenGL_Version_4_0 OpenGL version 4.0 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 static bool cachedDefault = false; static OpenGLVersionFlags defaultVersionFlags = OpenGL_Version_None; QGLContext *currentCtx = const_cast<QGLContext *>(QGLContext::currentContext()); QGLTemporaryContext *tmpContext = 0; if (currentCtx && currentCtx->d_func()->version_flags_cached) return currentCtx->d_func()->version_flags; if (!currentCtx) { if (cachedDefault) { return defaultVersionFlags; else { if (!hasOpenGL()) return defaultVersionFlags; tmpContext = new QGLTemporaryContext; cachedDefault = true; } }

QString versionString(QLatin1String(reinterpret_cast<const char*>(glGetString(GL_VERSION)))); OpenGLVersionFlags versionFlags = qOpenGLVersionFlagsFromString(versionString); if (currentCtx) { currentCtx->d_func()->version_flags_cached = true; currentCtx->d_func()->version_flags = versionFlags; } if (tmpContext) { defaultVersionFlags = versionFlags; delete tmpContext; }

return versionFlags; }

/*! Returns the default QGLFormat for the application. All QGLWidget objects 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()
Enumerator
OpenGL_Version_None 
OpenGL_Version_1_1 
OpenGL_Version_1_2 
OpenGL_Version_1_3 
OpenGL_Version_1_4 
OpenGL_Version_1_5 
OpenGL_Version_2_0 
OpenGL_Version_2_1 
OpenGL_ES_Common_Version_1_0 
OpenGL_ES_CommonLite_Version_1_0 
OpenGL_ES_Common_Version_1_1 
OpenGL_ES_CommonLite_Version_1_1 
OpenGL_ES_Version_2_0 
OpenGL_Version_3_0 
OpenGL_Version_3_1 
OpenGL_Version_3_2 
OpenGL_Version_3_3 
OpenGL_Version_4_0 

Definition at line 261 of file qgl.h.

261  {
262  OpenGL_Version_None = 0x00000000,
263  OpenGL_Version_1_1 = 0x00000001,
264  OpenGL_Version_1_2 = 0x00000002,
265  OpenGL_Version_1_3 = 0x00000004,
266  OpenGL_Version_1_4 = 0x00000008,
267  OpenGL_Version_1_5 = 0x00000010,
268  OpenGL_Version_2_0 = 0x00000020,
269  OpenGL_Version_2_1 = 0x00000040,
270  OpenGL_ES_Common_Version_1_0 = 0x00000080,
272  OpenGL_ES_Common_Version_1_1 = 0x00000200,
274  OpenGL_ES_Version_2_0 = 0x00000800,
275  OpenGL_Version_3_0 = 0x00001000,
276  OpenGL_Version_3_1 = 0x00002000,
277  OpenGL_Version_3_2 = 0x00004000,
278  OpenGL_Version_3_3 = 0x00008000,
279  OpenGL_Version_4_0 = 0x00010000
280  };

Constructors and Destructors

◆ QGLFormat() [1/3]

QGLFormat::QGLFormat ( )

Constructs a QGLFormat object with the following default settings:

Definition at line 449 of file qgl.cpp.

450 {
451  d = new QGLFormatPrivate;
452 }
QGLFormatPrivate * d
Definition: qgl.h:290

◆ QGLFormat() [2/3]

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

Creates a QGLFormat object that is a copy of the current defaultFormat().

If options is not 0, the default format is modified by the specified format options. The options parameter should be QGL::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)
{
if (!format().stencil())
qWarning("Could not get stencil buffer; results will be suboptimal");
if (!format().alpha())
qWarning("Could not get alpha channel; results will be suboptimal");
...
}

Note that there are QGL::FormatOption values to turn format settings both on and off, e.g. QGL::DepthBuffer and QGL::NoDepthBuffer, QGL::DirectRendering and QGL::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(), setPlane()

Definition at line 478 of file qgl.cpp.

479 {
480  d = new QGLFormatPrivate;
481  QGL::FormatOptions newOpts = options;
482  d->opts = defaultFormat().d->opts;
483  d->opts |= (newOpts & 0xffff);
484  d->opts &= ~(newOpts >> 16);
485  d->pln = plane;
486 }
int plane() const
Returns the plane of this format.
Definition: qgl.cpp:924
QGL::FormatOptions opts
Definition: qgl_p.h:156
QGLFormatPrivate * d
Definition: qgl.h:290
static QGLFormat defaultFormat()
Definition: qgl.cpp:1518

◆ QGLFormat() [3/3]

QGLFormat::QGLFormat ( const QGLFormat other)

Constructs a copy of other.

Definition at line 505 of file qgl.cpp.

506 {
507  d = other.d;
508  d->ref.ref();
509 }
bool ref()
Atomically increments the value of this QAtomicInt.
QGLFormatPrivate * d
Definition: qgl.h:290
QAtomicInt ref
Definition: qgl_p.h:155

◆ ~QGLFormat()

QGLFormat::~QGLFormat ( )

Destroys the QGLFormat.

Definition at line 529 of file qgl.cpp.

530 {
531  if (!d->ref.deref())
532  delete d;
533 }
bool deref()
Atomically decrements the value of this QAtomicInt.
QGLFormatPrivate * d
Definition: qgl.h:290
QAtomicInt ref
Definition: qgl_p.h:155

Functions

◆ accum()

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 633 of file qgl.h.

Referenced by buildSpec(), QGLContext::choosePixelFormat(), QGLContext::chooseVisual(), nearest_gl_texture_size(), pfdToQGLFormat(), pfiToQGLFormat(), QGLGraphicsSystem::QGLGraphicsSystem(), qt_format_to_attrib_list(), and QGLContextPrivate::tryFormat().

634 {
636 }
bool testOption(QGL::FormatOptions opt) const
Returns true if format option opt is set; otherwise returns false.
Definition: qgl.cpp:971

◆ accumBufferSize()

int QGLFormat::accumBufferSize ( ) const

Returns the accumulation buffer size.

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

Definition at line 1159 of file qgl.cpp.

Referenced by buildSpec(), nearest_gl_texture_size(), pfiToQGLFormat(), qt_format_to_attrib_list(), and QGLContextPrivate::tryFormat().

1160 {
1161  return d->accumSize;
1162 }
QGLFormatPrivate * d
Definition: qgl.h:290

◆ alpha()

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 628 of file qgl.h.

Referenced by QGLWindowSurface::beginPaint(), buildSpec(), QGLContext::choosePixelFormat(), QGLContext::chooseVisual(), nearest_gl_texture_size(), pfdToQGLFormat(), pfiToQGLFormat(), QGLGraphicsSystem::QGLGraphicsSystem(), qt_eglproperties_set_glformat(), qt_format_to_attrib_list(), QGLContextPrivate::tryFormat(), and QGLContext::tryVisual().

629 {
631 }
bool testOption(QGL::FormatOptions opt) const
Returns true if format option opt is set; otherwise returns false.
Definition: qgl.cpp:971

◆ alphaBufferSize()

int QGLFormat::alphaBufferSize ( ) const

◆ blueBufferSize()

int QGLFormat::blueBufferSize ( ) const

Returns the blue buffer size.

Since
4.2
See also
setBlueBufferSize()

Definition at line 1105 of file qgl.cpp.

Referenced by buildSpec(), QGLPaintDevice::metric(), nearest_gl_texture_size(), pfiToQGLFormat(), qt_eglproperties_set_glformat(), qt_format_to_attrib_list(), and QGLContextPrivate::tryFormat().

1106 {
1107  return d->blueSize;
1108 }
QGLFormatPrivate * d
Definition: qgl.h:290

◆ defaultFormat()

QGLFormat QGLFormat::defaultFormat ( )
static

◆ defaultOverlayFormat()

QGLFormat QGLFormat::defaultOverlayFormat ( )
static

Returns the default QGLFormat for overlay contexts.

The default overlay format is:

See also
setDefaultFormat()

Definition at line 1559 of file qgl.cpp.

Referenced by QGLContext::choosePixelFormat(), QGLOverlayWidget::paintGL(), and qStoreColors().

1560 {
1561  return *defaultOverlayFormatInstance();
1562 }

◆ depth()

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 618 of file qgl.h.

Referenced by buildSpec(), QGLContext::choosePixelFormat(), QGLContext::chooseVisual(), nearest_gl_texture_size(), pfdToQGLFormat(), pfiToQGLFormat(), QGLGraphicsSystem::QGLGraphicsSystem(), qt_eglproperties_set_glformat(), qt_format_to_attrib_list(), and QGLContextPrivate::tryFormat().

619 {
621 }
bool testOption(QGL::FormatOptions opt) const
Returns true if format option opt is set; otherwise returns false.
Definition: qgl.cpp:971

◆ depthBufferSize()

int QGLFormat::depthBufferSize ( ) const

Returns the depth buffer size.

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

Definition at line 1000 of file qgl.cpp.

Referenced by buildSpec(), nearest_gl_texture_size(), pfiToQGLFormat(), qt_eglproperties_set_glformat(), qt_format_to_attrib_list(), and QGLContextPrivate::tryFormat().

1001 {
1002  return d->depthSize;
1003 }
QGLFormatPrivate * d
Definition: qgl.h:290

◆ detach()

void QGLFormat::detach ( )
private
Warning
This function is not part of the public interface.

Definition at line 491 of file qgl.cpp.

492 {
493  if (d->ref != 1) {
494  QGLFormatPrivate *newd = new QGLFormatPrivate(d);
495  if (!d->ref.deref())
496  delete d;
497  d = newd;
498  }
499 }
bool deref()
Atomically decrements the value of this QAtomicInt.
QGLFormatPrivate * d
Definition: qgl.h:290
QAtomicInt ref
Definition: qgl_p.h:155

◆ directRendering()

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 648 of file qgl.h.

Referenced by QGLContext::choosePixelFormat(), and pfiToQGLFormat().

649 {
651 }
bool testOption(QGL::FormatOptions opt) const
Returns true if format option opt is set; otherwise returns false.
Definition: qgl.cpp:971

◆ doubleBuffer()

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 613 of file qgl.h.

Referenced by buildSpec(), QGLContext::choosePixelFormat(), QGLContext::chooseVisual(), QGLWindowSurface::flush(), pfiToQGLFormat(), qt_format_to_attrib_list(), and QGLContextPrivate::tryFormat().

614 {
616 }
bool testOption(QGL::FormatOptions opt) const
Returns true if format option opt is set; otherwise returns false.
Definition: qgl.cpp:971

◆ greenBufferSize()

int QGLFormat::greenBufferSize ( ) const

Returns the green buffer size.

Since
4.2
See also
setGreenBufferSize()

Definition at line 1070 of file qgl.cpp.

Referenced by buildSpec(), QGLPaintDevice::metric(), nearest_gl_texture_size(), pfiToQGLFormat(), qt_eglproperties_set_glformat(), qt_format_to_attrib_list(), and QGLContextPrivate::tryFormat().

1071 {
1072  return d->greenSize;
1073 }
QGLFormatPrivate * d
Definition: qgl.h:290

◆ hasOpenGL()

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 186 of file qgl_egl.cpp.

Referenced by qglx_getProcAddress(), qwglError(), and QGLTemporaryContext::~QGLTemporaryContext().

187 {
188  return true;
189 }

◆ hasOpenGLOverlays()

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 185 of file qgl_mac.mm.

Referenced by qDeleteQGLContext(), and qglx_getProcAddress().

186 {
187  return false;
188 }

◆ hasOverlay()

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 653 of file qgl.h.

Referenced by QGLContext::choosePixelFormat(), QGLOverlayWidget::paintGL(), and pfiToQGLFormat().

654 {
655  return testOption(QGL::HasOverlay);
656 }
bool testOption(QGL::FormatOptions opt) const
Returns true if format option opt is set; otherwise returns false.
Definition: qgl.cpp:971

◆ majorVersion()

int QGLFormat::majorVersion ( ) const

Returns the OpenGL major version.

Since
4.7
See also
setVersion(), minorVersion()

Definition at line 1223 of file qgl.cpp.

Referenced by QGL2PaintEngineEx::beginNativePainting(), and qgl_create_context().

1224 {
1225  return d->majorVersion;
1226 }
int majorVersion
Definition: qgl_p.h:167
QGLFormatPrivate * d
Definition: qgl.h:290

◆ minorVersion()

int QGLFormat::minorVersion ( ) const

Returns the OpenGL minor version.

Since
4.7
See also
setVersion(), majorVersion()

Definition at line 1238 of file qgl.cpp.

Referenced by QGL2PaintEngineEx::beginNativePainting(), and qgl_create_context().

1239 {
1240  return d->minorVersion;
1241 }
int minorVersion
Definition: qgl_p.h:168
QGLFormatPrivate * d
Definition: qgl.h:290

◆ openGLVersionFlags()

static OpenGLVersionFlags QGLFormat::openGLVersionFlags ( )
static

◆ operator=()

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

Assigns other to this object.

Definition at line 515 of file qgl.cpp.

516 {
517  if (d != other.d) {
518  other.d->ref.ref();
519  if (!d->ref.deref())
520  delete d;
521  d = other.d;
522  }
523  return *this;
524 }
bool ref()
Atomically increments the value of this QAtomicInt.
bool deref()
Atomically decrements the value of this QAtomicInt.
QGLFormatPrivate * d
Definition: qgl.h:290
QAtomicInt ref
Definition: qgl_p.h:155

◆ plane()

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

Definition at line 924 of file qgl.cpp.

Referenced by buildSpec(), nearest_gl_texture_size(), qgl_create_context(), and QGLContextPrivate::tryFormat().

925 {
926  return d->pln;
927 }
QGLFormatPrivate * d
Definition: qgl.h:290

◆ profile()

QGLFormat::OpenGLContextProfile QGLFormat::profile ( ) const

Returns the OpenGL context profile.

Since
4.7
See also
setProfile()

Definition at line 1286 of file qgl.cpp.

Referenced by QGL2PaintEngineEx::beginNativePainting(), and qgl_create_context().

1287 {
1288  return d->profile;
1289 }
QGLFormatPrivate * d
Definition: qgl.h:290
QGLFormat::OpenGLContextProfile profile
Definition: qgl_p.h:169

◆ redBufferSize()

int QGLFormat::redBufferSize ( ) const

Returns the red buffer size.

Since
4.2
See also
setRedBufferSize()

Definition at line 1035 of file qgl.cpp.

Referenced by buildSpec(), QGLPaintDevice::metric(), nearest_gl_texture_size(), pfiToQGLFormat(), qt_eglproperties_set_glformat(), qt_format_to_attrib_list(), and QGLContextPrivate::tryFormat().

1036 {
1037  return d->redSize;
1038 }
QGLFormatPrivate * d
Definition: qgl.h:290

◆ rgba()

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 623 of file qgl.h.

Referenced by buildSpec(), QGLContext::chooseContext(), QGLContext::choosePixelFormat(), QGLContext::chooseVisual(), and pfiToQGLFormat().

624 {
625  return testOption(QGL::Rgba);
626 }
Definition: qgl.h:147
bool testOption(QGL::FormatOptions opt) const
Returns true if format option opt is set; otherwise returns false.
Definition: qgl.cpp:971

◆ sampleBuffers()

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 658 of file qgl.h.

Referenced by buildSpec(), QGLContext::chooseVisual(), nearest_gl_texture_size(), pfiToQGLFormat(), QGLGraphicsSystem::QGLGraphicsSystem(), qt_eglproperties_set_glformat(), qt_format_to_attrib_list(), QGLContextPrivate::tryFormat(), and QGLWindowSurface::updateGeometry().

659 {
661 }
bool testOption(QGL::FormatOptions opt) const
Returns true if format option opt is set; otherwise returns false.
Definition: qgl.cpp:971

◆ samples()

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 824 of file qgl.cpp.

Referenced by buildSpec(), nearest_gl_texture_size(), pfiToQGLFormat(), qt_eglproperties_set_glformat(), qt_format_to_attrib_list(), and QGLContextPrivate::tryFormat().

825 {
826  return d->numSamples;
827 }
int numSamples
Definition: qgl_p.h:165
QGLFormatPrivate * d
Definition: qgl.h:290

◆ setAccum()

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 694 of file qgl.cpp.

Referenced by QGLContext::chooseVisual(), pfdToQGLFormat(), pfiToQGLFormat(), QGLGraphicsSystem::QGLGraphicsSystem(), and qt_format_to_attrib_list().

695 {
697 }
void setOption(QGL::FormatOptions opt)
Sets the format option to opt.
Definition: qgl.cpp:954

◆ setAccumBufferSize()

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 1143 of file qgl.cpp.

Referenced by pfdToQGLFormat(), pfiToQGLFormat(), QGLGraphicsSystem::QGLGraphicsSystem(), and qt_glformat_from_eglconfig().

1144 {
1145  detach();
1146  if (size < 0) {
1147  qWarning("QGLFormat::setAccumBufferSize: Cannot set negative accumulate buffer size %d", size);
1148  return;
1149  }
1150  d->accumSize = size;
1151  setAccum(size > 0);
1152 }
void detach()
Definition: qgl.cpp:491
Q_CORE_EXPORT void qWarning(const char *,...)
QGLFormatPrivate * d
Definition: qgl.h:290
void setAccum(bool enable)
If enable is true enables the accumulation buffer; otherwise disables the accumulation buffer...
Definition: qgl.cpp:694

◆ setAlpha()

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 664 of file qgl.cpp.

Referenced by QGLContext::chooseVisual(), QGLWindowSurface::hijackWindow(), pfdToQGLFormat(), pfiToQGLFormat(), QGLGraphicsSystem::QGLGraphicsSystem(), and QMeeGoGraphicsSystem::setTranslucent().

665 {
667 }
void setOption(QGL::FormatOptions opt)
Sets the format option to opt.
Definition: qgl.cpp:954

◆ setAlphaBufferSize()

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 1116 of file qgl.cpp.

Referenced by QGLOverlayWidget::paintGL(), pfdToQGLFormat(), pfiToQGLFormat(), QGLGraphicsSystem::QGLGraphicsSystem(), and qt_glformat_from_eglconfig().

1117 {
1118  detach();
1119  if (size < 0) {
1120  qWarning("QGLFormat::setAlphaBufferSize: Cannot set negative alpha buffer size %d", size);
1121  return;
1122  }
1123  d->alphaSize = size;
1124  setAlpha(size > 0);
1125 }
void setAlpha(bool enable)
If enable is true enables the alpha buffer; otherwise disables the alpha buffer.
Definition: qgl.cpp:664
void detach()
Definition: qgl.cpp:491
Q_CORE_EXPORT void qWarning(const char *,...)
QGLFormatPrivate * d
Definition: qgl.h:290

◆ setBlueBufferSize()

void QGLFormat::setBlueBufferSize ( int  size)

Set the preferred blue buffer size to size.

Since
4.2
See also
setRedBufferSize(), setGreenBufferSize(), setAlphaBufferSize()

Definition at line 1085 of file qgl.cpp.

Referenced by pfdToQGLFormat(), pfiToQGLFormat(), QGLGraphicsSystem::QGLGraphicsSystem(), and qt_glformat_from_eglconfig().

1086 {
1087  detach();
1088  if (size < 0) {
1089  qWarning("QGLFormat::setBlueBufferSize: Cannot set negative blue buffer size %d", size);
1090  return;
1091  }
1092  d->blueSize = size;
1093 }
void detach()
Definition: qgl.cpp:491
Q_CORE_EXPORT void qWarning(const char *,...)
QGLFormatPrivate * d
Definition: qgl.h:290

◆ setDefaultFormat()

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 1532 of file qgl.cpp.

1533 {
1534  *qgl_default_format() = f;
1535 }

◆ setDefaultOverlayFormat()

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 1583 of file qgl.cpp.

1584 {
1585  QGLFormat *defaultFormat = defaultOverlayFormatInstance();
1586  *defaultFormat = f;
1587  // Make sure the user doesn't request that the overlays themselves
1588  // have overlays, since it is unlikely that the system supports
1589  // infinitely many planes...
1590  defaultFormat->setOverlay(false);
1591 }
void setOverlay(bool enable)
If enable is true enables an overlay plane; otherwise disables the overlay plane. ...
Definition: qgl.cpp:912
The QGLFormat class specifies the display format of an OpenGL rendering context.
Definition: qgl.h:175
static QGLFormat defaultFormat()
Definition: qgl.cpp:1518

◆ setDepth()

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 599 of file qgl.cpp.

Referenced by QGLContext::chooseVisual(), pfdToQGLFormat(), pfiToQGLFormat(), QGLGraphicsSystem::QGLGraphicsSystem(), and QGLFBOGLPaintDevice::setFBO().

600 {
602 }
void setOption(QGL::FormatOptions opt)
Sets the format option to opt.
Definition: qgl.cpp:954

◆ setDepthBufferSize()

void QGLFormat::setDepthBufferSize ( int  size)

Set the minimum depth buffer size to size.

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

Definition at line 984 of file qgl.cpp.

Referenced by pfdToQGLFormat(), pfiToQGLFormat(), QGLGraphicsSystem::QGLGraphicsSystem(), and qt_glformat_from_eglconfig().

985 {
986  detach();
987  if (size < 0) {
988  qWarning("QGLFormat::setDepthBufferSize: Cannot set negative depth buffer size %d", size);
989  return;
990  }
991  d->depthSize = size;
992  setDepth(size > 0);
993 }
void detach()
Definition: qgl.cpp:491
Q_CORE_EXPORT void qWarning(const char *,...)
void setDepth(bool enable)
If enable is true enables the depth buffer; otherwise disables the depth buffer.
Definition: qgl.cpp:599
QGLFormatPrivate * d
Definition: qgl.h:290

◆ setDirectRendering()

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 787 of file qgl.cpp.

Referenced by pfdToQGLFormat(), pfiToQGLFormat(), and qt_glformat_from_eglconfig().

788 {
790 }
void setOption(QGL::FormatOptions opt)
Sets the format option to opt.
Definition: qgl.cpp:954

◆ setDoubleBuffer()

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.

Note that single buffered contexts are currently not supported with EGL.

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

Definition at line 566 of file qgl.cpp.

Referenced by QGLContext::chooseVisual(), pfdToQGLFormat(), pfiToQGLFormat(), QGLGraphicsSystem::QGLGraphicsSystem(), and qt_glformat_from_eglconfig().

567 {
569 }
void setOption(QGL::FormatOptions opt)
Sets the format option to opt.
Definition: qgl.cpp:954

◆ setGreenBufferSize()

void QGLFormat::setGreenBufferSize ( int  size)

Set the preferred green buffer size to size.

Since
4.2
See also
setRedBufferSize(), setBlueBufferSize(), setAlphaBufferSize()

Definition at line 1050 of file qgl.cpp.

Referenced by pfdToQGLFormat(), pfiToQGLFormat(), QGLGraphicsSystem::QGLGraphicsSystem(), and qt_glformat_from_eglconfig().

1051 {
1052  detach();
1053  if (size < 0) {
1054  qWarning("QGLFormat::setGreenBufferSize: Cannot set negative green buffer size %d", size);
1055  return;
1056  }
1057  d->greenSize = size;
1058 }
void detach()
Definition: qgl.cpp:491
Q_CORE_EXPORT void qWarning(const char *,...)
QGLFormatPrivate * d
Definition: qgl.h:290

◆ setOption()

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

Sets the format option to opt.

See also
testOption()

Definition at line 954 of file qgl.cpp.

955 {
956  detach();
957  if (opt & 0xffff)
958  d->opts |= opt;
959  else
960  d->opts &= ~(opt >> 16);
961 }
void detach()
Definition: qgl.cpp:491
QGL::FormatOptions opts
Definition: qgl_p.h:156
QGLFormatPrivate * d
Definition: qgl.h:290

◆ setOverlay()

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 912 of file qgl.cpp.

Referenced by pfdToQGLFormat(), and pfiToQGLFormat().

913 {
915 }
void setOption(QGL::FormatOptions opt)
Sets the format option to opt.
Definition: qgl.cpp:954

◆ setPlane()

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 942 of file qgl.cpp.

Referenced by QGLGraphicsSystem::QGLGraphicsSystem(), and qt_glformat_from_eglconfig().

943 {
944  detach();
945  d->pln = plane;
946 }
void detach()
Definition: qgl.cpp:491
int plane() const
Returns the plane of this format.
Definition: qgl.cpp:924
QGLFormatPrivate * d
Definition: qgl.h:290

◆ setProfile()

void QGLFormat::setProfile ( OpenGLContextProfile  profile)

Set the OpenGL context profile to profile.

Since
4.7

The profile is ignored if the requested OpenGL version is less than 3.2.

See also
profile()

Definition at line 1270 of file qgl.cpp.

1271 {
1272  detach();
1273  d->profile = profile;
1274 }
OpenGLContextProfile profile() const
Returns the OpenGL context profile.
Definition: qgl.cpp:1286
void detach()
Definition: qgl.cpp:491
QGLFormatPrivate * d
Definition: qgl.h:290
QGLFormat::OpenGLContextProfile profile
Definition: qgl_p.h:169

◆ setRedBufferSize()

void QGLFormat::setRedBufferSize ( int  size)

Set the preferred red buffer size to size.

Since
4.2
See also
setGreenBufferSize(), setBlueBufferSize(), setAlphaBufferSize()

Definition at line 1015 of file qgl.cpp.

Referenced by pfdToQGLFormat(), pfiToQGLFormat(), QGLGraphicsSystem::QGLGraphicsSystem(), and qt_glformat_from_eglconfig().

1016 {
1017  detach();
1018  if (size < 0) {
1019  qWarning("QGLFormat::setRedBufferSize: Cannot set negative red buffer size %d", size);
1020  return;
1021  }
1022  d->redSize = size;
1023 }
void detach()
Definition: qgl.cpp:491
Q_CORE_EXPORT void qWarning(const char *,...)
QGLFormatPrivate * d
Definition: qgl.h:290

◆ setRgba()

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 633 of file qgl.cpp.

Referenced by pfdToQGLFormat(), pfiToQGLFormat(), QGLGraphicsSystem::QGLGraphicsSystem(), and qt_glformat_from_eglconfig().

634 {
635  setOption(enable ? QGL::Rgba : QGL::ColorIndex);
636 }
Definition: qgl.h:147
void setOption(QGL::FormatOptions opt)
Sets the format option to opt.
Definition: qgl.cpp:954

◆ setSampleBuffers()

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 812 of file qgl.cpp.

Referenced by QGLContext::chooseVisual(), QGLWindowSurface::hijackWindow(), pfiToQGLFormat(), QGLGraphicsSystem::QGLGraphicsSystem(), and QMeeGoGraphicsSystem::setTranslucent().

813 {
815 }
void setOption(QGL::FormatOptions opt)
Sets the format option to opt.
Definition: qgl.cpp:954

◆ setSamples()

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 836 of file qgl.cpp.

Referenced by QGLWindowSurface::hijackWindow(), pfiToQGLFormat(), QGLGraphicsSystem::QGLGraphicsSystem(), qt_glformat_from_eglconfig(), and QMeeGoGraphicsSystem::setTranslucent().

837 {
838  detach();
839  if (numSamples < 0) {
840  qWarning("QGLFormat::setSamples: Cannot have negative number of samples per pixel %d", numSamples);
841  return;
842  }
843  d->numSamples = numSamples;
844  setSampleBuffers(numSamples > 0);
845 }
int numSamples
Definition: qgl_p.h:165
void setSampleBuffers(bool enable)
If enable is true, a GL context with multisample buffer support is picked; otherwise ignored...
Definition: qgl.cpp:812
void detach()
Definition: qgl.cpp:491
Q_CORE_EXPORT void qWarning(const char *,...)
QGLFormatPrivate * d
Definition: qgl.h:290

◆ setStencil()

void QGLFormat::setStencil ( bool  enable)

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

The stencil buffer is enabled 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 724 of file qgl.cpp.

Referenced by QGLContext::chooseVisual(), pfdToQGLFormat(), pfiToQGLFormat(), and QGLGraphicsSystem::QGLGraphicsSystem().

725 {
727 }
void setOption(QGL::FormatOptions opt)
Sets the format option to opt.
Definition: qgl.cpp:954

◆ setStencilBufferSize()

void QGLFormat::setStencilBufferSize ( int  size)

Set the preferred stencil buffer size to size.

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

Definition at line 1169 of file qgl.cpp.

Referenced by pfdToQGLFormat(), pfiToQGLFormat(), QGLGraphicsSystem::QGLGraphicsSystem(), and qt_glformat_from_eglconfig().

1170 {
1171  detach();
1172  if (size < 0) {
1173  qWarning("QGLFormat::setStencilBufferSize: Cannot set negative stencil buffer size %d", size);
1174  return;
1175  }
1176  d->stencilSize = size;
1177  setStencil(size > 0);
1178 }
void setStencil(bool enable)
If enable is true enables the stencil buffer; otherwise disables the stencil buffer.
Definition: qgl.cpp:724
void detach()
Definition: qgl.cpp:491
Q_CORE_EXPORT void qWarning(const char *,...)
QGLFormatPrivate * d
Definition: qgl.h:290
int stencilSize
Definition: qgl_p.h:160

◆ setStereo()

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 754 of file qgl.cpp.

Referenced by QGLContext::chooseVisual(), pfdToQGLFormat(), pfiToQGLFormat(), QGLGraphicsSystem::QGLGraphicsSystem(), and qt_glformat_from_eglconfig().

755 {
757 }
void setOption(QGL::FormatOptions opt)
Sets the format option to opt.
Definition: qgl.cpp:954

◆ setSwapInterval()

void QGLFormat::setSwapInterval ( int  interval)

Set the preferred swap interval.

Since
4.2

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 and under X11, where the WGL_EXT_swap_control and GLX_SGI_video_sync extensions are 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.

Under Windows the WGL_EXT_swap_control extension has to be present, and under X11 the GLX_SGI_video_sync extension has to be present.

Definition at line 868 of file qgl.cpp.

869 {
870  detach();
871  d->swapInterval = interval;
872 }
void detach()
Definition: qgl.cpp:491
QGLFormatPrivate * d
Definition: qgl.h:290
int swapInterval
Definition: qgl_p.h:166

◆ setVersion()

void QGLFormat::setVersion ( int  major,
int  minor 
)

Set the OpenGL version to the major and minor numbers.

Since
4.7

If a context compatible with the requested OpenGL version cannot be created, a context compatible with version 1.x is created instead.

See also
majorVersion(), minorVersion()

Definition at line 1202 of file qgl.cpp.

1203 {
1204  if (major < 1 || minor < 0) {
1205  qWarning("QGLFormat::setVersion: Cannot set zero or negative version number %d.%d", major, minor);
1206  return;
1207  }
1208  detach();
1209  d->majorVersion = major;
1210  d->minorVersion = minor;
1211 }
void detach()
Definition: qgl.cpp:491
int minorVersion
Definition: qgl_p.h:168
int majorVersion
Definition: qgl_p.h:167
Q_CORE_EXPORT void qWarning(const char *,...)
QGLFormatPrivate * d
Definition: qgl.h:290

◆ stencil()

bool QGLFormat::stencil ( ) const
inline

Returns true if the stencil buffer is enabled; otherwise returns false.

The stencil buffer is enabled by default.

See also
setStencil(), setStencilBufferSize()

Definition at line 638 of file qgl.h.

Referenced by buildSpec(), QGLContext::choosePixelFormat(), QGLContext::chooseVisual(), QGL2PaintEngineExPrivate::fill(), nearest_gl_texture_size(), pfdToQGLFormat(), pfiToQGLFormat(), QGLGraphicsSystem::QGLGraphicsSystem(), qt_eglproperties_set_glformat(), qt_format_to_attrib_list(), and QGLContextPrivate::tryFormat().

639 {
641 }
bool testOption(QGL::FormatOptions opt) const
Returns true if format option opt is set; otherwise returns false.
Definition: qgl.cpp:971

◆ stencilBufferSize()

int QGLFormat::stencilBufferSize ( ) const

Returns the stencil buffer size.

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

Definition at line 1185 of file qgl.cpp.

Referenced by buildSpec(), nearest_gl_texture_size(), pfiToQGLFormat(), qt_eglproperties_set_glformat(), qt_format_to_attrib_list(), and QGLContextPrivate::tryFormat().

1186 {
1187  return d->stencilSize;
1188 }
QGLFormatPrivate * d
Definition: qgl.h:290
int stencilSize
Definition: qgl_p.h:160

◆ stereo()

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 643 of file qgl.h.

Referenced by buildSpec(), QGLContext::choosePixelFormat(), QGLContext::chooseVisual(), nearest_gl_texture_size(), pfiToQGLFormat(), qt_format_to_attrib_list(), and QGLContextPrivate::tryFormat().

644 {
646 }
bool testOption(QGL::FormatOptions opt) const
Returns true if format option opt is set; otherwise returns false.
Definition: qgl.cpp:971

◆ swapInterval()

int QGLFormat::swapInterval ( ) const

Returns the currently set swap interval.

Since
4.2

-1 is returned if setting the swap interval isn't supported in the system GL implementation.

Definition at line 883 of file qgl.cpp.

884 {
885  return d->swapInterval;
886 }
QGLFormatPrivate * d
Definition: qgl.h:290
int swapInterval
Definition: qgl_p.h:166

◆ testOption()

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

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

See also
setOption()

Definition at line 971 of file qgl.cpp.

Referenced by qgl_create_context().

972 {
973  if (opt & 0xffff)
974  return (d->opts & opt) != 0;
975  else
976  return (d->opts & (opt >> 16)) == 0;
977 }
QGL::FormatOptions opts
Definition: qgl_p.h:156
QGLFormatPrivate * d
Definition: qgl.h:290

Friends and Related Functions

◆ operator!=

bool operator!= ( const QGLFormat a,
const QGLFormat b 
)
friend

Returns false if all the options of the two QGLFormat objects a and b are equal; otherwise returns true.

Definition at line 1653 of file qgl.cpp.

1654 {
1655  return !(a == b);
1656 }

◆ operator<<

Q_OPENGL_EXPORT QDebug operator<< ( QDebug  ,
const QGLFormat  
)
friend

Definition at line 1620 of file qgl.cpp.

1621 {
1622  const QGLFormatPrivate * const d = f.d;
1623 
1624  dbg.nospace() << "QGLFormat("
1625  << "options " << d->opts
1626  << ", plane " << d->pln
1627  << ", depthBufferSize " << d->depthSize
1628  << ", accumBufferSize " << d->accumSize
1629  << ", stencilBufferSize " << d->stencilSize
1630  << ", redBufferSize " << d->redSize
1631  << ", greenBufferSize " << d->greenSize
1632  << ", blueBufferSize " << d->blueSize
1633  << ", alphaBufferSize " << d->alphaSize
1634  << ", samples " << d->numSamples
1635  << ", swapInterval " << d->swapInterval
1636  << ", majorVersion " << d->majorVersion
1637  << ", minorVersion " << d->minorVersion
1638  << ", profile " << d->profile
1639  << ')';
1640 
1641  return dbg.space();
1642 }
int numSamples
Definition: qgl_p.h:165
QDebug & nospace()
Clears the stream&#39;s internal flag that records whether the last character was a space and returns a r...
Definition: qdebug.h:92
int minorVersion
Definition: qgl_p.h:168
int majorVersion
Definition: qgl_p.h:167
QGL::FormatOptions opts
Definition: qgl_p.h:156
QGLFormatPrivate * d
Definition: qgl.h:290
QGLFormat::OpenGLContextProfile profile
Definition: qgl_p.h:169
QDebug & space()
Writes a space character to the debug stream and returns a reference to the stream.
Definition: qdebug.h:91
int swapInterval
Definition: qgl_p.h:166
int stencilSize
Definition: qgl_p.h:160

◆ operator==

bool operator== ( const QGLFormat a,
const QGLFormat b 
)
friend

Returns true if all the options of the two QGLFormat objects a and b are equal; otherwise returns false.

Definition at line 1601 of file qgl.cpp.

1602 {
1603  return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts
1604  && a.d->pln == b.d->pln
1605  && a.d->alphaSize == b.d->alphaSize
1606  && a.d->accumSize == b.d->accumSize
1607  && a.d->stencilSize == b.d->stencilSize
1608  && a.d->depthSize == b.d->depthSize
1609  && a.d->redSize == b.d->redSize
1610  && a.d->greenSize == b.d->greenSize
1611  && a.d->blueSize == b.d->blueSize
1612  && a.d->numSamples == b.d->numSamples
1613  && a.d->swapInterval == b.d->swapInterval
1614  && a.d->majorVersion == b.d->majorVersion
1615  && a.d->minorVersion == b.d->minorVersion
1616  && a.d->profile == b.d->profile);
1617 }
int numSamples
Definition: qgl_p.h:165
int minorVersion
Definition: qgl_p.h:168
int majorVersion
Definition: qgl_p.h:167
QGL::FormatOptions opts
Definition: qgl_p.h:156
QGLFormatPrivate * d
Definition: qgl.h:290
QGLFormat::OpenGLContextProfile profile
Definition: qgl_p.h:169
int swapInterval
Definition: qgl_p.h:166
int stencilSize
Definition: qgl_p.h:160

Properties

◆ d

QGLFormatPrivate* QGLFormat::d
private

The documentation for this class was generated from the following files: