PythonQt.QtGui.QOpenGLContext · declarations 001
Back to PythonQt.QtGui.QOpenGLContext
LibGL
instance-attribute
LibGL: Any
LibGLES
instance-attribute
LibGLES: Any
OpenGLModuleType
instance-attribute
OpenGLModuleType: type
int([x]) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.int(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by '+' or '-' and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal.
int('0b100', base=0) 4
aboutToBeDestroyed
aboutToBeDestroyed(*args: Any, **kwargs: Any) -> Any
Native PythonQt.QtGui.QOpenGLContext.aboutToBeDestroyed; argument details are not documented.
Supplemental documentation: Qt 5 reference:
[signal] void QOpenGLContext::aboutToBeDestroyed()
This signal is emitted before the underlying native OpenGL context is destroyed, such that users may clean up OpenGL resources that might otherwise be left dangling in the case of shared OpenGL contexts.
If you wish to make the context current in order to do clean-up, make sure to only connect to the signal using a direct connection.
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#aboutToBeDestroyed
areSharing
areSharing(first: Any, second: Any) -> bool
X.areSharing(first, second) -> bool
Supplemental documentation: Qt 5 reference:
[static] bool QOpenGLContext::areSharing(QOpenGLContext *first, QOpenGLContext *second)
Returns true if the first and second contexts are sharing OpenGL resources.
Upstream PySide2 reference signatures (binding differences may apply):
areSharing(first: PySide2.QtGui.QOpenGLContext, second: PySide2.QtGui.QOpenGLContext) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#areSharing
create
create() -> bool
X.create() -> bool
Supplemental documentation: Qt 5 reference:
bool QOpenGLContext::create()
Attempts to create the OpenGL context with the current configuration.
The current configuration includes the format, the share context, and the screen.
If the OpenGL implementation on your system does not support the requested version of OpenGL context, then QOpenGLContext will try to create the closest matching version. The actual created context properties can be queried using the QSurfaceFormat returned by the format() function. For example, if you request a context that supports OpenGL 4.3 Core profile but the driver and/or hardware only supports version 3.2 Core profile contexts then you will get a 3.2 Core profile context.
Returns true if the native context was successfully created and is ready to be used
with
makeCurrent(),
swapBuffers(),
etc.
Note: If the context already exists, this function destroys the existing context first, and then creates a new one.
See also makeCurrent() and format().
Upstream PySide2 reference signatures (binding differences may apply):
create(self) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#create
currentContext
currentContext() -> Any
X.currentContext() -> PythonQt.QtGui.QOpenGLContext
Supplemental documentation: Qt 5 reference:
[static] QOpenGLContext *QOpenGLContext::currentContext()
Returns the last context which called
makeCurrent in the
current thread, or nullptr, if no context is current.
Upstream PySide2 reference signatures (binding differences may apply):
currentContext() -> PySide2.QtGui.QOpenGLContext
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#currentContext
defaultFramebufferObject
defaultFramebufferObject() -> int
X.defaultFramebufferObject() -> int
Supplemental documentation: Qt 5 reference:
GLuint QOpenGLContext::defaultFramebufferObject() const
Call this to get the default framebuffer object for the current surface.
On some platforms (for instance, iOS) the default framebuffer object depends on the surface being rendered to, and might be different from 0. Thus, instead of calling glBindFramebuffer(0), you should call glBindFramebuffer(ctx->defaultFramebufferObject()) if you want your application to work across different Qt platforms.
If you use the glBindFramebuffer() in QOpenGLFunctions you do not have to worry about this, as it automatically binds the current context's defaultFramebufferObject() when 0 is passed.
Note: Widgets that render via framebuffer objects, like QOpenGLWidget and QQuickWidget, will override the value returned from this function when painting is active, because at that time the correct "default" framebuffer is the widget's associated backing framebuffer, not the platform-specific one belonging to the top-level window's surface. This ensures the expected behavior for this function and other classes relying on it (for example, QOpenGLFramebufferObject::bindDefault() or QOpenGLFramebufferObject::release()).
See also QOpenGLFramebufferObject.
Upstream PySide2 reference signatures (binding differences may apply):
defaultFramebufferObject(self) -> int
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#defaultFramebufferObject
destroyed
destroyed(*args: Any, **kwargs: Any) -> Any
Native PythonQt.QtGui.QOpenGLContext.destroyed; argument details are not documented.
doneCurrent
doneCurrent() -> None
X.doneCurrent()
Supplemental documentation: Qt 5 reference:
void QOpenGLContext::doneCurrent()
Convenience function for calling makeCurrent with a 0 surface.
This results in no context being current in the current thread.
See also makeCurrent() and currentContext().
Upstream PySide2 reference signatures (binding differences may apply):
doneCurrent(self) -> None
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#doneCurrent
extensions
extensions() -> Any
X.extensions()
Supplemental documentation: Qt 5 reference:
QSet\<QByteArray> QOpenGLContext::extensions() const
Returns the set of OpenGL extensions supported by this context.
The context or a sharing context must be current.
See also hasExtension().
Upstream PySide2 reference signatures (binding differences may apply):
extensions(self) -> typing.Set[PySide2.QtCore.QByteArray]
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#extensions
format
format() -> Any
X.format() -> PythonQt.QtGui.QSurfaceFormat
Supplemental documentation: Qt 5 reference:
QSurfaceFormat QOpenGLContext::format() const
Returns the format of the underlying platform context, if create() has been called.
Otherwise, returns the requested format.
The requested and the actual format may differ. Requesting a given OpenGL version does not mean the resulting context will target exactly the requested version. It is only guaranteed that the version/profile/options combination for the created context is compatible with the request, as long as the driver is able to provide such a context.
For example, requesting an OpenGL version 3.x core profile context may result in an OpenGL 4.x core profile context. Similarly, a request for OpenGL 2.1 may result in an OpenGL 3.0 context with deprecated functions enabled. Finally, depending on the driver, unsupported versions may result in either a context creation failure or in a context for the highest supported version.
Similar differences are possible in the buffer sizes, for example, the resulting context may have a larger depth buffer than requested. This is perfectly normal.
See also setFormat().
Upstream PySide2 reference signatures (binding differences may apply):
format(self) -> PySide2.QtGui.QSurfaceFormat
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#format
functions
functions() -> Any
X.functions()
Supplemental documentation: Qt 5 reference:
QOpenGLFunctions *QOpenGLContext::functions() const
Get the QOpenGLFunctions instance for this context.
QOpenGLContext offers this as a convenient way to access QOpenGLFunctions without having to manage it manually.
The context or a sharing context must be current.
The returned QOpenGLFunctions instance is ready to be used and it does not need initializeOpenGLFunctions() to be called.
Upstream PySide2 reference signatures (binding differences may apply):
functions(self) -> PySide2.QtGui.QOpenGLFunctions
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#functions
globalShareContext
globalShareContext() -> Any
X.globalShareContext() -> PythonQt.QtGui.QOpenGLContext
Supplemental documentation: Qt 5 reference:
[static] QOpenGLContext *QOpenGLContext::globalShareContext()
Returns the application-wide shared OpenGL context, if present. Otherwise, returns
nullptr.
This is useful if you need to upload OpenGL objects (buffers, textures, etc.) before creating or showing a QOpenGLWidget or QQuickWidget.
Note: You must set the Qt::AA_ShareOpenGLContexts flag on QGuiApplication before creating the QGuiApplication object, otherwise Qt may not create a global shared context.
Warning: Do not attempt to make the context returned by this function current on any surface. Instead, you can create a new context which shares with the global one, and then make the new context current.
This function was introduced in Qt 5.5.
See also Qt::AA_ShareOpenGLContexts, setShareContext(), and makeCurrent().
Upstream PySide2 reference signatures (binding differences may apply):
globalShareContext() -> PySide2.QtGui.QOpenGLContext
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#globalShareContext
hasExtension
hasExtension(extension: Any) -> bool
X.hasExtension(extension) -> bool
Supplemental documentation: Qt 5 reference:
bool QOpenGLContext::hasExtension(const QByteArray \&extension) const
Returns true if this OpenGL context supports the specified OpenGL extension, false
otherwise.
The context or a sharing context must be current.
See also extensions().
Upstream PySide2 reference signatures (binding differences may apply):
hasExtension(self, extension: PySide2.QtCore.QByteArray) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#hasExtension
isOpenGLES
isOpenGLES() -> bool
X.isOpenGLES() -> bool
Supplemental documentation: Qt 5 reference:
bool QOpenGLContext::isOpenGLES() const
Returns true if the context is an OpenGL ES context.
If the context has not yet been created, the result is based on the requested format set via setFormat().
This function was introduced in Qt 5.3.
See also create(), format(), and setFormat().
Upstream PySide2 reference signatures (binding differences may apply):
isOpenGLES(self) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#isOpenGLES
isValid
isValid() -> bool
X.isValid() -> bool
Supplemental documentation: Qt 5 reference:
bool QOpenGLContext::isValid() const
Returns if this context is valid, i.e. has been successfully created.
On some platforms the return value of false for a context that was successfully
created previously indicates that the OpenGL context was lost.
The typical way to handle context loss scenarios in applications is to check via this
function whenever
makeCurrent()
fails and returns false. If this function then returns false, recreate the
underlying native OpenGL context by calling
create(), call
makeCurrent()
again and then reinitialize all OpenGL resources.
On some platforms context loss situations is not something that can avoided. On others
however, they may need to be opted-in to. This can be done by enabling
ResetNotification
in the QSurfaceFormat. This
will lead to setting RESET_NOTIFICATION_STRATEGY_EXT to LOSE_CONTEXT_ON_RESET_EXT in
the underlying native OpenGL context.
QOpenGLContext will then
monitor the status via glGetGraphicsResetStatusEXT() in every
makeCurrent().
See also create().
Upstream PySide2 reference signatures (binding differences may apply):
isValid(self) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#isValid
makeCurrent
makeCurrent(surface: Any) -> bool
X.makeCurrent(surface) -> bool
Supplemental documentation: Qt 5 reference:
bool QOpenGLContext::makeCurrent(QSurface *surface)
Makes the context current in the current thread, against the given surface. Returns
true if successful; otherwise returns false. The latter may happen if the surface is
not exposed, or the graphics hardware is not available due to e.g. the application being
suspended.
If surface is nullptr this is equivalent to calling
doneCurrent().
Avoid calling this function from a different thread than the one the QOpenGLContext instance lives in. If you wish to use QOpenGLContext from a different thread you should first make sure it's not current in the current thread, by calling doneCurrent() if necessary. Then call moveToThread(otherThread) before using it in the other thread.
By default Qt employs a check that enforces the above condition on the thread affinity.
It is still possible to disable this check by setting the
Qt::AA_DontCheckOpenGLContextThreadAffinity application attribute. Be sure to
understand the consequences of using QObjects from outside the thread they live in, as
explained in the QObject thread
affinity
documentation.
See also functions(), doneCurrent(), and Qt::AA_DontCheckOpenGLContextThreadAffinity.
Upstream PySide2 reference signatures (binding differences may apply):
makeCurrent(self, surface: PySide2.QtGui.QSurface) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#makeCurrent
nativeHandle
nativeHandle() -> Any
X.nativeHandle() -> object
Supplemental documentation: Qt 5 reference:
QVariant QOpenGLContext::nativeHandle() const
Returns the native handle for the context.
This function provides access to the QOpenGLContext's underlying native context. The returned variant contains a platform-specific value type. These classes can be found in the module QtPlatformHeaders.
On platforms where retrieving the native handle is not supported, or if neither create() nor setNativeHandle() was called, a null variant is returned.
This function was introduced in Qt 5.4.
See also setNativeHandle().
Upstream PySide2 reference signatures (binding differences may apply):
nativeHandle(self) -> typing.Any
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#nativeHandle
objectNameChanged
objectNameChanged(*args: Any, **kwargs: Any) -> Any
Native PythonQt.QtGui.QOpenGLContext.objectNameChanged; argument details are not documented.
openGLModuleHandle
openGLModuleHandle() -> int
X.openGLModuleHandle()
Supplemental documentation: Qt 5 reference:
[static] void *QOpenGLContext::openGLModuleHandle()
Returns the platform-specific handle for the OpenGL implementation that is currently in use. (for example, a HMODULE on Windows)
On platforms that do not use dynamic GL switching, the return value is nullptr.
The library might be GL-only, meaning that windowing system interface functions (for example EGL) may live in another, separate library.
Note: This function requires that the QGuiApplication instance is already created.
This function was introduced in Qt 5.3.
See also openGLModuleType().
Upstream PySide2 reference signatures (binding differences may apply):
openGLModuleHandle() -> int
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#openGLModuleHandle
openGLModuleType
openGLModuleType() -> Any
X.openGLModuleType()
Supplemental documentation: Qt 5 reference:
[static] QOpenGLContext::OpenGLModuleType QOpenGLContext::openGLModuleType()
Returns the underlying OpenGL implementation type.
On platforms where the OpenGL implementation is not dynamically loaded, the return value is determined during compile time and never changes.
Note: A desktop OpenGL implementation may be capable of creating ES-compatible contexts too. Therefore in most cases it is more appropriate to check QSurfaceFormat::renderableType() or use the convenience function isOpenGLES().
Note: This function requires that the QGuiApplication instance is already created.
This function was introduced in Qt 5.3.
Upstream PySide2 reference signatures (binding differences may apply):
openGLModuleType() -> PySide2.QtGui.QOpenGLContext.OpenGLModuleType
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#openGLModuleType
screen
screen() -> Any
X.screen() -> PythonQt.QtGui.QScreen
Supplemental documentation: Qt 5 reference:
QScreen *QOpenGLContext::screen() const
Returns the screen the context was created for.
See also setScreen().
Upstream PySide2 reference signatures (binding differences may apply):
screen(self) -> PySide2.QtGui.QScreen
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#screen
setFormat
setFormat(format: Any) -> None
X.setFormat(format)
Supplemental documentation: Qt 5 reference:
void QOpenGLContext::setFormat(const QSurfaceFormat \&format)
Sets the format the OpenGL context should be compatible with. You need to call create() before it takes effect.
When the format is not explicitly set via this function, the format returned by QSurfaceFormat::defaultFormat() will be used. This means that when having multiple contexts, individual calls to this function can be replaced by one single call to QSurfaceFormat::setDefaultFormat() before creating the first context.
See also format().
Upstream PySide2 reference signatures (binding differences may apply):
setFormat(self, format: PySide2.QtGui.QSurfaceFormat) -> None
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#setFormat
setNativeHandle
setNativeHandle(handle: Any) -> None
X.setNativeHandle(handle)
Supplemental documentation: Qt 5 reference:
void QOpenGLContext::setNativeHandle(const QVariant \&handle)
Set the native handles for this context. When create() is called and a native handle is set, configuration settings, like format(), are ignored since this QOpenGLContext will wrap an already created native context instead of creating a new one from scratch.
On some platforms the native context handle is not sufficient and other related handles (for example, for a window or display) have to be provided in addition. Therefore handle is variant containing a platform-specific value type. These classes can be found in the QtPlatformHeaders module.
When create() is called with native handles set, QOpenGLContext does not take ownership of the handles, so destroying the QOpenGLContext does not destroy the native context.
Note: Some frameworks track the current context and surfaces internally. Making the adopted QOpenGLContext current via Qt will have no effect on such other frameworks' internal state. Therefore a subsequent makeCurrent done via the other framework may have no effect. It is therefore advisable to make explicit calls to make no context and surface current to reset the other frameworks' internal state after performing OpenGL operations via Qt.
Note: Using foreign contexts with Qt windows and Qt contexts with windows and surfaces created by other frameworks may give unexpected results, depending on the platform, due to potential mismatches in context and window pixel formats. To make sure this does not happen, avoid making contexts and surfaces from different frameworks current together. Instead, prefer approaches based on context sharing where OpenGL resources like textures are accessible both from Qt's and the foreign framework's contexts.
This function was introduced in Qt 5.4.
See also nativeHandle().
Upstream PySide2 reference signatures (binding differences may apply):
setNativeHandle(self, handle: typing.Any) -> None
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#setNativeHandle
setScreen
setScreen(screen: Any) -> None
X.setScreen(screen)
Supplemental documentation: Qt 5 reference:
void QOpenGLContext::setScreen(QScreen *screen)
Sets the screen the OpenGL context should be valid for. You need to call create() before it takes effect.
See also screen().
Upstream PySide2 reference signatures (binding differences may apply):
setScreen(self, screen: PySide2.QtGui.QScreen) -> None
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#setScreen
setShareContext
setShareContext(shareContext: Any) -> None
X.setShareContext(shareContext)
Supplemental documentation: Qt 5 reference:
void QOpenGLContext::setShareContext(QOpenGLContext *shareContext)
Makes this context share textures, shaders, and other OpenGL resources with shareContext. You need to call create() before it takes effect.
See also shareContext().
Upstream PySide2 reference signatures (binding differences may apply):
setShareContext(self, shareContext: PySide2.QtGui.QOpenGLContext) -> None
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#setShareContext
shareContext
shareContext() -> Any
X.shareContext() -> PythonQt.QtGui.QOpenGLContext
Supplemental documentation: Qt 5 reference:
QOpenGLContext *QOpenGLContext::shareContext() const
Returns the share context this context was created with.
If the underlying platform was not able to support the requested sharing, this will return 0.
See also setShareContext().
Upstream PySide2 reference signatures (binding differences may apply):
shareContext(self) -> PySide2.QtGui.QOpenGLContext
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#shareContext
shareGroup
shareGroup() -> Any
X.shareGroup() -> PythonQt.QtGui.QOpenGLContextGroup
Supplemental documentation: Qt 5 reference:
QOpenGLContextGroup *QOpenGLContext::shareGroup() const
Returns the share group this context belongs to.
Upstream PySide2 reference signatures (binding differences may apply):
shareGroup(self) -> PySide2.QtGui.QOpenGLContextGroup
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#shareGroup
supportsThreadedOpenGL
supportsThreadedOpenGL() -> bool
X.supportsThreadedOpenGL() -> bool
Supplemental documentation: Qt 5 reference:
[static] bool QOpenGLContext::supportsThreadedOpenGL()
Returns true if the platform supports OpenGL rendering outside the main (gui) thread.
The value is controlled by the platform plugin in use and may also depend on the graphics drivers.
This function was introduced in Qt 5.5.
Upstream PySide2 reference signatures (binding differences may apply):
supportsThreadedOpenGL() -> bool
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#supportsThreadedOpenGL
surface
surface() -> Any
X.surface() -> PythonQt.QtGui.QSurface
Supplemental documentation: Qt 5 reference:
QSurface *QOpenGLContext::surface() const
Returns the surface the context has been made current with.
This is the surface passed as an argument to makeCurrent().
Upstream PySide2 reference signatures (binding differences may apply):
surface(self) -> PySide2.QtGui.QSurface
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#surface
swapBuffers
swapBuffers(surface: Any) -> None
X.swapBuffers(surface)
Supplemental documentation: Qt 5 reference:
void QOpenGLContext::swapBuffers(QSurface *surface)
Swap the back and front buffers of surface.
Call this to finish a frame of OpenGL rendering, and make sure to call makeCurrent() again before issuing any further OpenGL commands, for example as part of a new frame.
Upstream PySide2 reference signatures (binding differences may apply):
swapBuffers(self, surface: PySide2.QtGui.QSurface) -> None
Source: https://doc.qt.io/archives/qt-5.15/qopenglcontext.html#swapBuffers