Skip to content

PythonQt.QtOpenGL.QGLFormat

QGLFormat

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

Detailed Description

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:

QGLFormat fmt;
fmt.setAlpha(true);
fmt.setStereo(true);
QGLFormat::setDefaultFormat(fmt);

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

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

After the widget has been created, you can find out which of the requested features the system was able to provide:

QGLFormat fmt;
fmt.setOverlay(true);
fmt.setStereo(true);
MyGLWidget* myWidget = new MyGLWidget(fmt, ...);
if (!myWidget->format().stereo()) {
    // ok, goggles off
    if (!myWidget->format().hasOverlay()) {
        qFatal("Cool hardware required");
    }
}

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

Source: https://doc.qt.io/archives/qt-5.15/qglformat.html

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
CompatibilityProfile attribute Any (shared captured text)
CoreProfile attribute Any (shared captured text)
NoProfile attribute Any (shared captured text)
OpenGLContextProfile attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
OpenGLVersionFlag attribute type Convert a number or string to an integer, or return 0 if no arguments are given.
OpenGLVersionFlags attribute type Convert a number or string to an integer, or return 0 if no arguments are given.
OpenGL_ES_CommonLite_Version_1_0 attribute Any
OpenGL_ES_CommonLite_Version_1_1 attribute Any
OpenGL_ES_Common_Version_1_0 attribute Any
OpenGL_ES_Common_Version_1_1 attribute Any
OpenGL_ES_Version_2_0 attribute Any
OpenGL_Version_1_1 attribute Any
OpenGL_Version_1_2 attribute Any
OpenGL_Version_1_3 attribute Any
OpenGL_Version_1_4 attribute Any
OpenGL_Version_1_5 attribute Any
OpenGL_Version_2_0 attribute Any
OpenGL_Version_2_1 attribute Any
OpenGL_Version_3_0 attribute Any
OpenGL_Version_3_1 attribute Any
OpenGL_Version_3_2 attribute Any
OpenGL_Version_3_3 attribute Any
OpenGL_Version_4_0 attribute Any
OpenGL_Version_4_1 attribute Any
OpenGL_Version_4_2 attribute Any
OpenGL_Version_4_3 attribute Any
OpenGL_Version_None attribute Any
__init__ function (self, *args: Any, **kwargs: Any) -> None Native constructor; consult class documentation for supported overloads. (shared captured text)
accum function (self) -> bool X.accum() -> bool
accumBufferSize function (self) -> int X.accumBufferSize() -> int
alpha function (self) -> bool X.alpha() -> bool
alphaBufferSize function (self) -> int X.alphaBufferSize() -> int
blueBufferSize function (self) -> int X.blueBufferSize() -> int
className function (self, *args: Any, **kwargs: Any) -> Any Return the classname of the object (shared captured text)
defaultFormat function (self) -> Any X.defaultFormat() -> PythonQt.QtOpenGL.QGLFormat
defaultOverlayFormat function (self) -> Any X.defaultOverlayFormat() -> PythonQt.QtOpenGL.QGLFormat
delete function (self, *args: Any, **kwargs: Any) -> Any Deletes the C++ object (at your own risk, my friend!) (shared captured text)
depth function (self) -> bool X.depth() -> bool
depthBufferSize function (self) -> int X.depthBufferSize() -> int
directRendering function (self) -> bool X.directRendering() -> bool
doubleBuffer function (self) -> bool X.doubleBuffer() -> bool
fromSurfaceFormat function (self, format: Any) -> Any X.fromSurfaceFormat(format) -> PythonQt.QtOpenGL.QGLFormat
greenBufferSize function (self) -> int X.greenBufferSize() -> int
hasOpenGL function (self) -> bool X.hasOpenGL() -> bool
hasOpenGLOverlays function (self) -> bool X.hasOpenGLOverlays() -> bool
hasOverlay function (self) -> bool X.hasOverlay() -> bool
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
inherits function (self, *args: Any, **kwargs: Any) -> Any Returns if the class inherits or is of given type name (shared captured text)
majorVersion function (self) -> int X.majorVersion() -> int
minorVersion function (self) -> int X.minorVersion() -> int
openGLVersionFlags function (self) -> Any Identifies, at runtime, which OpenGL versions that are supported by the current platform.
plane function (self) -> int X.plane() -> int
profile function (self) -> Any Returns the OpenGL context profile.
redBufferSize function (self) -> int X.redBufferSize() -> int
rgba function (self) -> bool X.rgba() -> bool
sampleBuffers function (self) -> bool X.sampleBuffers() -> bool
samples function (self) -> int X.samples() -> int
setAccum function (self, enable: bool) -> None If enable is true enables the accumulation buffer; otherwise disables the accumulation buffer.
setAccumBufferSize function (self, size: int) -> None Set the preferred accumulation buffer size, where size is the bit depth for each RGBA component.
setAlpha function (self, enable: bool) -> None If enable is true enables the alpha buffer; otherwise disables the alpha buffer.
setAlphaBufferSize function (self, size: int) -> None Set the preferred alpha buffer size to size.
setBlueBufferSize function (self, size: int) -> None Set the preferred blue buffer size to size.
setDefaultFormat function (self, f: Any) -> None
setDefaultOverlayFormat function (self, f: Any) -> None Sets a new default [QGLFormat](https://doc.qt.io/archives/qt-5.15/qglformat.html) for overlay contexts to f.
setDepth function (self, enable: bool) -> None If enable is true enables the depth buffer; otherwise disables the depth buffer.
setDepthBufferSize function (self, size: int) -> None Set the minimum depth buffer size to size.
setDirectRendering function (self, enable: bool) -> None If enable is true enables direct rendering; otherwise disables direct rendering.
setDoubleBuffer function (self, enable: bool) -> None If enable is true sets double buffering; otherwise sets single buffering.
setGreenBufferSize function (self, size: int) -> None Set the preferred green buffer size to size.
setOption function (self, opt: Any) -> None Sets the format option to opt.
setOverlay function (self, enable: bool) -> None If enable is true enables an overlay plane; otherwise disables the overlay plane.
setPlane function (self, plane: int) -> None 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.
setProfile function (self, profile: Any) -> None Set the OpenGL context profile to profile.
setRedBufferSize function (self, size: int) -> None Set the preferred red buffer size to size.
setRgba function (self, enable: bool) -> None If enable is true sets RGBA mode.
setSampleBuffers function (self, enable: bool) -> None If enable is true, a GL context with multisample buffer support is picked; otherwise ignored.
setSamples function (self, numSamples: int) -> None Set the preferred number of samples per pixel when multisampling is enabled to numSamples.
setStencil function (self, enable: bool) -> None If enable is true enables the stencil buffer; otherwise disables the stencil buffer.
setStencilBufferSize function (self, size: int) -> None Set the preferred stencil buffer size to size.
setStereo function (self, enable: bool) -> None If enable is true enables stereo buffering; otherwise disables stereo buffering.
setSwapInterval function (self, interval: int) -> None Set the preferred swap interval.
setVersion function (self, major: int, minor: int) -> None X.setVersion(major, minor)
stencil function (self) -> bool X.stencil() -> bool
stencilBufferSize function (self) -> int X.stencilBufferSize() -> int
stereo function (self) -> bool X.stereo() -> bool
swapInterval function (self) -> int X.swapInterval() -> int
testOption function (self, opt: Any) -> bool X.testOption(opt) -> bool
toSurfaceFormat function (self, format: Any) -> Any X.toSurfaceFormat(format) -> PythonQt.QtGui.QSurfaceFormat