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

The QPlatformWindowFormat class specifies the display format of an OpenGL rendering context and if possible attributes of the corresponding QPlatformWindow. More...

#include <qplatformwindowformat_qpa.h>

Public Types

enum  FormatOption {
  DoubleBuffer = 0x0001, DepthBuffer = 0x0002, Rgba = 0x0004, AlphaChannel = 0x0008,
  AccumBuffer = 0x0010, StencilBuffer = 0x0020, StereoBuffers = 0x0040, DirectRendering = 0x0080,
  HasOverlay = 0x0100, SampleBuffers = 0x0200, DeprecatedFunctions = 0x0400, HasWindowSurface = 0x0800,
  SingleBuffer = DoubleBuffer << 16, NoDepthBuffer = DepthBuffer << 16, ColorIndex = Rgba << 16, NoAlphaChannel = AlphaChannel << 16,
  NoAccumBuffer = AccumBuffer << 16, NoStencilBuffer = StencilBuffer << 16, NoStereoBuffers = StereoBuffers << 16, IndirectRendering = DirectRendering << 16,
  NoOverlay = HasOverlay << 16, NoSampleBuffers = SampleBuffers << 16, NoDeprecatedFunctions = DeprecatedFunctions << 16, NoWindowSurface = HasWindowSurface << 16
}
 
enum  WindowApi { Raster, OpenGL, OpenVG }
 

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 hasWindowSurface () const
 Returns true if the corresponding widget has an instance of QWindowSurface. More...
 
QPlatformWindowFormatoperator= (const QPlatformWindowFormat &other)
 Assigns other to this object. More...
 
 QPlatformWindowFormat ()
 Constructs a QPlatformWindowFormat object with the following default settings: More...
 
 QPlatformWindowFormat (FormatOptions options)
 
 QPlatformWindowFormat (const QPlatformWindowFormat &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 (QPlatformWindowFormat::FormatOptions opt)
 Sets the format option to opt. 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 setSharedContext (QPlatformGLContext *context)
 
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 setWindowApi (QPlatformWindowFormat::WindowApi api)
 
void setWindowSurface (bool enable)
 If enable is true a top level QWidget will create a QWindowSurface at creation;. More...
 
QPlatformGLContextsharedGLContext () const
 
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 (QPlatformWindowFormat::FormatOptions opt) const
 Returns true if format option opt is set; otherwise returns false. More...
 
WindowApi windowApi () const
 
 ~QPlatformWindowFormat ()
 Destroys the QPlatformWindowFormat. More...
 

Static Public Functions

static QPlatformWindowFormat defaultFormat ()
 Returns the default QPlatformWindowFormat for the application. More...
 
static void setDefaultFormat (const QPlatformWindowFormat &f)
 Sets a new default QPlatformWindowFormat for the application to f. More...
 

Private Functions

void detach ()
 

Properties

QPlatformWindowFormatPrivated
 

Friends

Q_GUI_EXPORT bool operator!= (const QPlatformWindowFormat &, const QPlatformWindowFormat &)
 Returns false if all the options of the two QPlatformWindowFormat objects a and b are equal; otherwise returns true. More...
 
Q_GUI_EXPORT QDebug operator<< (QDebug, const QPlatformWindowFormat &)
 
Q_GUI_EXPORT bool operator== (const QPlatformWindowFormat &, const QPlatformWindowFormat &)
 Sets a new default QPlatformWindowFormat for overlay contexts to f. More...
 

Detailed Description

The QPlatformWindowFormat class specifies the display format of an OpenGL rendering context and if possible attributes of the corresponding QPlatformWindow.

Since
4.8

QWidget has a setter and getter function for QPlatformWindowFormat. These functions can be used by the application programmer to signal what kind of format he wants to the window and glcontext should have. However, it is not always possible to fulfill these requirements. The application programmer should therefore check the resulting QPlatformWindowFormat from QPlatformGLContext to see the format that was actually created.

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 QPlatformWindowFormat 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 QPlatformWindowFormat 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
QPlatformGLContext, QWidget

Definition at line 54 of file qplatformwindowformat_qpa.h.

Enumerations

◆ FormatOption

Enumerator
DoubleBuffer 
DepthBuffer 
Rgba 
AlphaChannel 
AccumBuffer 
StencilBuffer 
StereoBuffers 
DirectRendering 
HasOverlay 
SampleBuffers 
DeprecatedFunctions 
HasWindowSurface 
SingleBuffer 
NoDepthBuffer 
ColorIndex 
NoAlphaChannel 
NoAccumBuffer 
NoStencilBuffer 
NoStereoBuffers 
IndirectRendering 
NoOverlay 
NoSampleBuffers 
NoDeprecatedFunctions 
NoWindowSurface 

Definition at line 57 of file qplatformwindowformat_qpa.h.

57  {
58  DoubleBuffer = 0x0001,
59  DepthBuffer = 0x0002,
60  Rgba = 0x0004,
61  AlphaChannel = 0x0008,
62  AccumBuffer = 0x0010,
63  StencilBuffer = 0x0020,
64  StereoBuffers = 0x0040,
65  DirectRendering = 0x0080,
66  HasOverlay = 0x0100,
67  SampleBuffers = 0x0200,
68  DeprecatedFunctions = 0x0400,
69  HasWindowSurface = 0x0800,
70  SingleBuffer = DoubleBuffer << 16,
71  NoDepthBuffer = DepthBuffer << 16,
72  ColorIndex = Rgba << 16,
74  NoAccumBuffer = AccumBuffer << 16,
78  NoOverlay = HasOverlay << 16,
82 
83  };

◆ WindowApi

Constructors and Destructors

◆ QPlatformWindowFormat() [1/3]

QPlatformWindowFormat::QPlatformWindowFormat ( )

Constructs a QPlatformWindowFormat object with the following default settings:

Definition at line 190 of file qplatformwindowformat_qpa.cpp.

◆ QPlatformWindowFormat() [2/3]

QPlatformWindowFormat::QPlatformWindowFormat ( FormatOptions  options)

◆ QPlatformWindowFormat() [3/3]

QPlatformWindowFormat::QPlatformWindowFormat ( const QPlatformWindowFormat other)

Constructs a copy of other.

Definition at line 241 of file qplatformwindowformat_qpa.cpp.

242 {
243  d = other.d;
244  d->ref.ref();
245 }
QPlatformWindowFormatPrivate * d
bool ref()
Atomically increments the value of this QAtomicInt.

◆ ~QPlatformWindowFormat()

QPlatformWindowFormat::~QPlatformWindowFormat ( )

Destroys the QPlatformWindowFormat.

Definition at line 265 of file qplatformwindowformat_qpa.cpp.

266 {
267  if (!d->ref.deref())
268  delete d;
269 }
QPlatformWindowFormatPrivate * d
bool deref()
Atomically decrements the value of this QAtomicInt.

Functions

◆ accum()

bool QPlatformWindowFormat::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 200 of file qplatformwindowformat_qpa.h.

Referenced by qglx_buildSpec(), and qglx_reducePlatformWindowFormat().

201 {
203 }
bool testOption(QPlatformWindowFormat::FormatOptions opt) const
Returns true if format option opt is set; otherwise returns false.

◆ accumBufferSize()

int QPlatformWindowFormat::accumBufferSize ( ) const

Returns the accumulation buffer size.

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

Definition at line 879 of file qplatformwindowformat_qpa.cpp.

Referenced by qglx_buildSpec().

880 {
881  return d->accumSize;
882 }
QPlatformWindowFormatPrivate * d

◆ alpha()

bool QPlatformWindowFormat::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 195 of file qplatformwindowformat_qpa.h.

Referenced by q_createConfigAttributesFromFormat(), qglx_buildSpec(), qglx_findConfig(), and qglx_reducePlatformWindowFormat().

196 {
198 }
bool testOption(QPlatformWindowFormat::FormatOptions opt) const
Returns true if format option opt is set; otherwise returns false.

◆ alphaBufferSize()

int QPlatformWindowFormat::alphaBufferSize ( ) const

Returns the alpha buffer size.

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

Definition at line 852 of file qplatformwindowformat_qpa.cpp.

Referenced by q_createConfigAttributesFromFormat(), QBBGLContext::QBBGLContext(), and qglx_buildSpec().

853 {
854  return d->alphaSize;
855 }
QPlatformWindowFormatPrivate * d

◆ blueBufferSize()

int QPlatformWindowFormat::blueBufferSize ( ) const

◆ defaultFormat()

QPlatformWindowFormat QPlatformWindowFormat::defaultFormat ( )
static

Returns the default QPlatformWindowFormat 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 QPlatformWindowFormat().

See also
setDefaultFormat()

Definition at line 922 of file qplatformwindowformat_qpa.cpp.

Referenced by QEglFSScreen::createAndSetPlatformContext(), QWidgetPrivate::createTLExtra(), effectiveState(), and QBBIntegration::QBBIntegration().

923 {
924  return *q_platformwindow_default_format();
925 }

◆ depth()

bool QPlatformWindowFormat::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 185 of file qplatformwindowformat_qpa.h.

Referenced by q_createConfigAttributesFromFormat(), qglx_buildSpec(), and qglx_reducePlatformWindowFormat().

186 {
188 }
bool testOption(QPlatformWindowFormat::FormatOptions opt) const
Returns true if format option opt is set; otherwise returns false.

◆ depthBufferSize()

int QPlatformWindowFormat::depthBufferSize ( ) const

Returns the depth buffer size.

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

Definition at line 720 of file qplatformwindowformat_qpa.cpp.

Referenced by q_createConfigAttributesFromFormat(), and qglx_buildSpec().

721 {
722  return d->depthSize;
723 }
QPlatformWindowFormatPrivate * d

◆ detach()

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

Definition at line 227 of file qplatformwindowformat_qpa.cpp.

228 {
229  if (d->ref != 1) {
231  if (!d->ref.deref())
232  delete d;
233  d = newd;
234  }
235 }
QPlatformWindowFormatPrivate * d
bool deref()
Atomically decrements the value of this QAtomicInt.

◆ directRendering()

bool QPlatformWindowFormat::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 215 of file qplatformwindowformat_qpa.h.

216 {
218 }
bool testOption(QPlatformWindowFormat::FormatOptions opt) const
Returns true if format option opt is set; otherwise returns false.

◆ doubleBuffer()

bool QPlatformWindowFormat::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 180 of file qplatformwindowformat_qpa.h.

Referenced by qglx_buildSpec(), and qglx_reducePlatformWindowFormat().

181 {
183 }
bool testOption(QPlatformWindowFormat::FormatOptions opt) const
Returns true if format option opt is set; otherwise returns false.

◆ greenBufferSize()

int QPlatformWindowFormat::greenBufferSize ( ) const

◆ hasWindowSurface()

bool QPlatformWindowFormat::hasWindowSurface ( ) const
inline

Returns true if the corresponding widget has an instance of QWindowSurface.

Otherwise returns false.

WindowSurface is enabled by default.

Definition at line 220 of file qplatformwindowformat_qpa.h.

221 {
223 }
bool testOption(QPlatformWindowFormat::FormatOptions opt) const
Returns true if format option opt is set; otherwise returns false.

◆ operator=()

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

Assigns other to this object.

Definition at line 251 of file qplatformwindowformat_qpa.cpp.

252 {
253  if (d != other.d) {
254  other.d->ref.ref();
255  if (!d->ref.deref())
256  delete d;
257  d = other.d;
258  }
259  return *this;
260 }
QPlatformWindowFormatPrivate * d
bool ref()
Atomically increments the value of this QAtomicInt.
bool deref()
Atomically decrements the value of this QAtomicInt.

◆ redBufferSize()

int QPlatformWindowFormat::redBufferSize ( ) const

◆ rgba()

bool QPlatformWindowFormat::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 190 of file qplatformwindowformat_qpa.h.

Referenced by qglx_buildSpec().

191 {
193 }
bool testOption(QPlatformWindowFormat::FormatOptions opt) const
Returns true if format option opt is set; otherwise returns false.

◆ sampleBuffers()

bool QPlatformWindowFormat::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 225 of file qplatformwindowformat_qpa.h.

Referenced by q_createConfigAttributesFromFormat(), qglx_buildSpec(), qglx_platformWindowFromGLXFBConfig(), and qglx_reducePlatformWindowFormat().

226 {
228 }
bool testOption(QPlatformWindowFormat::FormatOptions opt) const
Returns true if format option opt is set; otherwise returns false.

◆ samples()

int QPlatformWindowFormat::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 557 of file qplatformwindowformat_qpa.cpp.

Referenced by q_createConfigAttributesFromFormat(), and qglx_buildSpec().

558 {
559  return d->numSamples;
560 }
QPlatformWindowFormatPrivate * d

◆ setAccum()

void QPlatformWindowFormat::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 427 of file qplatformwindowformat_qpa.cpp.

Referenced by EAGLPlatformContext::EAGLPlatformContext(), and qglx_reducePlatformWindowFormat().

◆ setAccumBufferSize()

void QPlatformWindowFormat::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 863 of file qplatformwindowformat_qpa.cpp.

Referenced by EAGLPlatformContext::EAGLPlatformContext(), QDirectFbGLContext::QDirectFbGLContext(), qglx_platformWindowFromGLXFBConfig(), and qt_qPlatformWindowFormatFromConfig().

864 {
865  detach();
866  if (size < 0) {
867  qWarning("QPlatformWindowFormat::setAccumBufferSize: Cannot set negative accumulate buffer size %d", size);
868  return;
869  }
870  d->accumSize = size;
871  setAccum(size > 0);
872 }
QPlatformWindowFormatPrivate * d
Q_CORE_EXPORT void qWarning(const char *,...)
void setAccum(bool enable)
If enable is true enables the accumulation buffer; otherwise disables the accumulation buffer...

◆ setAlpha()

void QPlatformWindowFormat::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 397 of file qplatformwindowformat_qpa.cpp.

Referenced by EAGLPlatformContext::EAGLPlatformContext(), effectiveState(), qDeleteQGLContext(), QDirectFbGLContext::QDirectFbGLContext(), and qglx_reducePlatformWindowFormat().

◆ setAlphaBufferSize()

void QPlatformWindowFormat::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 836 of file qplatformwindowformat_qpa.cpp.

Referenced by EAGLPlatformContext::EAGLPlatformContext(), QBBGLContext::QBBGLContext(), QDirectFbGLContext::QDirectFbGLContext(), qglx_platformWindowFromGLXFBConfig(), and qt_qPlatformWindowFormatFromConfig().

837 {
838  detach();
839  if (size < 0) {
840  qWarning("QPlatformWindowFormat::setAlphaBufferSize: Cannot set negative alpha buffer size %d", size);
841  return;
842  }
843  d->alphaSize = size;
844  setAlpha(size > 0);
845 }
QPlatformWindowFormatPrivate * d
Q_CORE_EXPORT void qWarning(const char *,...)
void setAlpha(bool enable)
If enable is true enables the alpha buffer; otherwise disables the alpha buffer.

◆ setBlueBufferSize()

void QPlatformWindowFormat::setBlueBufferSize ( int  size)

Set the preferred blue buffer size to size.

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

Definition at line 805 of file qplatformwindowformat_qpa.cpp.

Referenced by QXlibWindow::correctColorBuffers(), QEglFSScreen::createAndSetPlatformContext(), EAGLPlatformContext::EAGLPlatformContext(), QBBGLContext::QBBGLContext(), QDirectFbGLContext::QDirectFbGLContext(), qglx_platformWindowFromGLXFBConfig(), QOpenKODEWindow::QOpenKODEWindow(), and qt_qPlatformWindowFormatFromConfig().

806 {
807  detach();
808  if (size < 0) {
809  qWarning("QPlatformWindowFormat::setBlueBufferSize: Cannot set negative blue buffer size %d", size);
810  return;
811  }
812  d->blueSize = size;
813 }
QPlatformWindowFormatPrivate * d
Q_CORE_EXPORT void qWarning(const char *,...)

◆ setDefaultFormat()

void QPlatformWindowFormat::setDefaultFormat ( const QPlatformWindowFormat f)
static

Sets a new default QPlatformWindowFormat 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 936 of file qplatformwindowformat_qpa.cpp.

Referenced by QBBIntegration::QBBIntegration().

937 {
938  *q_platformwindow_default_format() = f;
939 }

◆ setDepth()

void QPlatformWindowFormat::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 332 of file qplatformwindowformat_qpa.cpp.

Referenced by QEglFSScreen::createAndSetPlatformContext(), EAGLPlatformContext::EAGLPlatformContext(), and qglx_reducePlatformWindowFormat().

◆ setDepthBufferSize()

void QPlatformWindowFormat::setDepthBufferSize ( int  size)

Set the minimum depth buffer size to size.

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

Definition at line 704 of file qplatformwindowformat_qpa.cpp.

Referenced by EAGLPlatformContext::EAGLPlatformContext(), QDirectFbGLContext::QDirectFbGLContext(), qglx_platformWindowFromGLXFBConfig(), and qt_qPlatformWindowFormatFromConfig().

705 {
706  detach();
707  if (size < 0) {
708  qWarning("QPlatformWindowFormat::setDepthBufferSize: Cannot set negative depth buffer size %d", size);
709  return;
710  }
711  d->depthSize = size;
712  setDepth(size > 0);
713 }
QPlatformWindowFormatPrivate * d
Q_CORE_EXPORT void qWarning(const char *,...)
void setDepth(bool enable)
If enable is true enables the depth buffer; otherwise disables the depth buffer.

◆ setDirectRendering()

void QPlatformWindowFormat::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 520 of file qplatformwindowformat_qpa.cpp.

Referenced by EAGLPlatformContext::EAGLPlatformContext(), qglx_platformWindowFromGLXFBConfig(), and qt_qPlatformWindowFormatFromConfig().

◆ setDoubleBuffer()

void QPlatformWindowFormat::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 299 of file qplatformwindowformat_qpa.cpp.

Referenced by EAGLPlatformContext::EAGLPlatformContext(), QDirectFbGLContext::QDirectFbGLContext(), and qglx_reducePlatformWindowFormat().

◆ setGreenBufferSize()

void QPlatformWindowFormat::setGreenBufferSize ( int  size)

Set the preferred green buffer size to size.

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

Definition at line 770 of file qplatformwindowformat_qpa.cpp.

Referenced by QXlibWindow::correctColorBuffers(), QEglFSScreen::createAndSetPlatformContext(), EAGLPlatformContext::EAGLPlatformContext(), QBBGLContext::QBBGLContext(), QDirectFbGLContext::QDirectFbGLContext(), qglx_platformWindowFromGLXFBConfig(), QOpenKODEWindow::QOpenKODEWindow(), and qt_qPlatformWindowFormatFromConfig().

771 {
772  detach();
773  if (size < 0) {
774  qWarning("QPlatformWindowFormat::setGreenBufferSize: Cannot set negative green buffer size %d", size);
775  return;
776  }
777  d->greenSize = size;
778 }
QPlatformWindowFormatPrivate * d
Q_CORE_EXPORT void qWarning(const char *,...)

◆ setOption()

void QPlatformWindowFormat::setOption ( QPlatformWindowFormat::FormatOptions  opt)

Sets the format option to opt.

See also
testOption()

Definition at line 674 of file qplatformwindowformat_qpa.cpp.

675 {
676  detach();
677  if (opt & 0xffff)
678  d->opts |= opt;
679  else
680  d->opts &= ~(opt >> 16);
681 }
QPlatformWindowFormat::FormatOptions opts
QPlatformWindowFormatPrivate * d

◆ setRedBufferSize()

void QPlatformWindowFormat::setRedBufferSize ( int  size)

Set the preferred red buffer size to size.

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

Definition at line 735 of file qplatformwindowformat_qpa.cpp.

Referenced by QXlibWindow::correctColorBuffers(), QEglFSScreen::createAndSetPlatformContext(), EAGLPlatformContext::EAGLPlatformContext(), QBBGLContext::QBBGLContext(), QDirectFbGLContext::QDirectFbGLContext(), qglx_platformWindowFromGLXFBConfig(), QOpenKODEWindow::QOpenKODEWindow(), and qt_qPlatformWindowFormatFromConfig().

736 {
737  detach();
738  if (size < 0) {
739  qWarning("QPlatformWindowFormat::setRedBufferSize: Cannot set negative red buffer size %d", size);
740  return;
741  }
742  d->redSize = size;
743 }
QPlatformWindowFormatPrivate * d
Q_CORE_EXPORT void qWarning(const char *,...)

◆ setRgba()

void QPlatformWindowFormat::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 366 of file qplatformwindowformat_qpa.cpp.

Referenced by EAGLPlatformContext::EAGLPlatformContext(), qglx_platformWindowFromGLXFBConfig(), and qt_qPlatformWindowFormatFromConfig().

◆ setSampleBuffers()

void QPlatformWindowFormat::setSampleBuffers ( bool  enable)

◆ setSamples()

void QPlatformWindowFormat::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 569 of file qplatformwindowformat_qpa.cpp.

Referenced by EAGLPlatformContext::EAGLPlatformContext(), qglx_platformWindowFromGLXFBConfig(), and qt_qPlatformWindowFormatFromConfig().

570 {
571  detach();
572  if (numSamples < 0) {
573  qWarning("QPlatformWindowFormat::setSamples: Cannot have negative number of samples per pixel %d", numSamples);
574  return;
575  }
576  d->numSamples = numSamples;
577  setSampleBuffers(numSamples > 0);
578 }
QPlatformWindowFormatPrivate * d
Q_CORE_EXPORT void qWarning(const char *,...)
void setSampleBuffers(bool enable)
If enable is true, a GL context with multisample buffer support is picked; otherwise ignored...

◆ setSharedContext()

void QPlatformWindowFormat::setSharedContext ( QPlatformGLContext context)

Definition at line 632 of file qplatformwindowformat_qpa.cpp.

Referenced by qDeleteQGLContext(), and QWaylandGLContext::QWaylandGLContext().

633 {
634  d->sharedContext = context;
635 }
QPlatformWindowFormatPrivate * d

◆ setStencil()

void QPlatformWindowFormat::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 457 of file qplatformwindowformat_qpa.cpp.

Referenced by EAGLPlatformContext::EAGLPlatformContext(), and qglx_reducePlatformWindowFormat().

◆ setStencilBufferSize()

void QPlatformWindowFormat::setStencilBufferSize ( int  size)

Set the preferred stencil buffer size to size.

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

Definition at line 889 of file qplatformwindowformat_qpa.cpp.

Referenced by EAGLPlatformContext::EAGLPlatformContext(), QDirectFbGLContext::QDirectFbGLContext(), qglx_platformWindowFromGLXFBConfig(), and qt_qPlatformWindowFormatFromConfig().

890 {
891  detach();
892  if (size < 0) {
893  qWarning("QPlatformWindowFormat::setStencilBufferSize: Cannot set negative stencil buffer size %d", size);
894  return;
895  }
896  d->stencilSize = size;
897  setStencil(size > 0);
898 }
QPlatformWindowFormatPrivate * d
Q_CORE_EXPORT void qWarning(const char *,...)
void setStencil(bool enable)
If enable is true enables the stencil buffer; otherwise disables the stencil buffer.

◆ setStereo()

void QPlatformWindowFormat::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 487 of file qplatformwindowformat_qpa.cpp.

Referenced by EAGLPlatformContext::EAGLPlatformContext(), QDirectFbGLContext::QDirectFbGLContext(), qglx_platformWindowFromGLXFBConfig(), qglx_reducePlatformWindowFormat(), and qt_qPlatformWindowFormatFromConfig().

◆ setSwapInterval()

void QPlatformWindowFormat::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 601 of file qplatformwindowformat_qpa.cpp.

602 {
603  detach();
604  d->swapInterval = interval;
605 }
QPlatformWindowFormatPrivate * d

◆ setWindowApi()

void QPlatformWindowFormat::setWindowApi ( QPlatformWindowFormat::WindowApi  api)

◆ setWindowSurface()

void QPlatformWindowFormat::setWindowSurface ( bool  enable)

If enable is true a top level QWidget will create a QWindowSurface at creation;.

otherwise the QWidget will only have a QPlatformWindow.

This is useful for QGLWidget where the QPlatformGLContext controls the surface.

Definition at line 663 of file qplatformwindowformat_qpa.cpp.

Referenced by qDeleteQGLContext().

◆ sharedGLContext()

QPlatformGLContext * QPlatformWindowFormat::sharedGLContext ( ) const

Definition at line 637 of file qplatformwindowformat_qpa.cpp.

Referenced by QXlibWindow::glContext(), QGLXContext::QGLXContext(), and QWaylandGLContext::QWaylandGLContext().

638 {
639  return d->sharedContext;
640 }
QPlatformWindowFormatPrivate * d

◆ stencil()

bool QPlatformWindowFormat::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 205 of file qplatformwindowformat_qpa.h.

Referenced by q_createConfigAttributesFromFormat(), qglx_buildSpec(), and qglx_reducePlatformWindowFormat().

206 {
208 }
bool testOption(QPlatformWindowFormat::FormatOptions opt) const
Returns true if format option opt is set; otherwise returns false.

◆ stencilBufferSize()

int QPlatformWindowFormat::stencilBufferSize ( ) const

Returns the stencil buffer size.

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

Definition at line 905 of file qplatformwindowformat_qpa.cpp.

Referenced by q_createConfigAttributesFromFormat(), and qglx_buildSpec().

906 {
907  return d->stencilSize;
908 }
QPlatformWindowFormatPrivate * d

◆ stereo()

bool QPlatformWindowFormat::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 210 of file qplatformwindowformat_qpa.h.

Referenced by qglx_buildSpec(), and qglx_reducePlatformWindowFormat().

211 {
213 }
bool testOption(QPlatformWindowFormat::FormatOptions opt) const
Returns true if format option opt is set; otherwise returns false.

◆ swapInterval()

int QPlatformWindowFormat::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 616 of file qplatformwindowformat_qpa.cpp.

617 {
618  return d->swapInterval;
619 }
QPlatformWindowFormatPrivate * d

◆ testOption()

bool QPlatformWindowFormat::testOption ( QPlatformWindowFormat::FormatOptions  opt) const

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

See also
setOption()

Definition at line 691 of file qplatformwindowformat_qpa.cpp.

692 {
693  if (opt & 0xffff)
694  return (d->opts & opt) != 0;
695  else
696  return (d->opts & (opt >> 16)) == 0;
697 }
QPlatformWindowFormat::FormatOptions opts
QPlatformWindowFormatPrivate * d

◆ windowApi()

QPlatformWindowFormat::WindowApi QPlatformWindowFormat::windowApi ( ) const

Definition at line 627 of file qplatformwindowformat_qpa.cpp.

Referenced by QBBWindow::glContext(), q_configFromQPlatformWindowFormat(), QBBGLContext::QBBGLContext(), and QBBWindow::QBBWindow().

628 {
629  return d->windowApi;
630 }
QPlatformWindowFormatPrivate * d
QPlatformWindowFormat::WindowApi windowApi

Friends and Related Functions

◆ operator!=

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

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

Since
4.8

Definition at line 1036 of file qplatformwindowformat_qpa.cpp.

1037 {
1038  return !(a == b);
1039 }

◆ operator<<

Q_GUI_EXPORT QDebug operator<< ( QDebug  ,
const QPlatformWindowFormat  
)
friend

Definition at line 1042 of file qplatformwindowformat_qpa.cpp.

1043 {
1044  const QPlatformWindowFormatPrivate * const d = f.d;
1045 
1046  dbg.nospace() << "QGLFormat("
1047  << "options " << d->opts
1048  << ", depthBufferSize " << d->depthSize
1049  << ", accumBufferSize " << d->accumSize
1050  << ", stencilBufferSize " << d->stencilSize
1051  << ", redBufferSize " << d->redSize
1052  << ", greenBufferSize " << d->greenSize
1053  << ", blueBufferSize " << d->blueSize
1054  << ", alphaBufferSize " << d->alphaSize
1055  << ", samples " << d->numSamples
1056  << ", swapInterval " << d->swapInterval
1057  << ')';
1058 
1059  return dbg.space();
1060 }
QPlatformWindowFormat::FormatOptions opts
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
QPlatformWindowFormatPrivate * d
QDebug & space()
Writes a space character to the debug stream and returns a reference to the stream.
Definition: qdebug.h:91

◆ operator==

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

Sets a new default QPlatformWindowFormat 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()

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

Since
4.8

Definition at line 1008 of file qplatformwindowformat_qpa.cpp.

1009 {
1010  return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts
1011  && a.d->alphaSize == b.d->alphaSize
1012  && a.d->accumSize == b.d->accumSize
1013  && a.d->stencilSize == b.d->stencilSize
1014  && a.d->depthSize == b.d->depthSize
1015  && a.d->redSize == b.d->redSize
1016  && a.d->greenSize == b.d->greenSize
1017  && a.d->blueSize == b.d->blueSize
1018  && a.d->numSamples == b.d->numSamples
1019  && a.d->swapInterval == b.d->swapInterval
1020  && a.d->windowApi == b.d->windowApi);
1021 }
QPlatformWindowFormat::FormatOptions opts
QPlatformWindowFormatPrivate * d
QPlatformWindowFormat::WindowApi windowApi

Properties

◆ d

QPlatformWindowFormatPrivate* QPlatformWindowFormat::d
private

Definition at line 160 of file qplatformwindowformat_qpa.h.

Referenced by operator<<(), operator=(), and QPlatformWindowFormat().


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