PySide6.QtGui.QRhiGles2InitParams¶
- class QRhiGles2InitParams¶
OpenGL specific initialization parameters. More…
Added in version 6.6.
Synopsis¶
Methods¶
def
__init__()
Static functions¶
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
Note
This is a RHI API with limited compatibility guarantees, see
QRhifor details.An OpenGL-based
QRhineeds an already createdQSurfacethat can be used in combination withQOpenGLContext. Most commonly, this is aQOffscreenSurfacein practice. Additionally, while optional, it is recommended that theQWindowthe firstQRhiSwapChainwill target is passed in as well.QOffscreenSurface *fallbackSurface = QRhiGles2InitParams::newFallbackSurface(); QRhiGles2InitParams params; params.fallbackSurface = fallbackSurface; params.window = window; rhi = QRhi::create(QRhi::OpenGLES2, ¶ms);
By default
QRhicreates aQOpenGLContexton its own. This approach works well in most cases, included threaded scenarios, where there is a dedicatedQRhifor each rendering thread. As there will be aQOpenGLContextfor eachQRhi, the OpenGL context requirements (a context can only be current on one thread) are satisfied. The implicitly created context is destroyed automatically together with theQRhi.The
QSurfaceFormatfor the context is specified informat. The constructor sets this todefaultFormat()so applications that callsetDefaultFormat()with the appropriate settings before the constructor runs will not need to change value offormat.Note
Remember to set the depth and stencil buffer sizes to 24 and 8 when the renderer relies on depth or stencil testing, either in the global default
QSurfaceFormat, or, alternatively, separately in all the involvedQSurfaceFormatinstances: informat, the format argument passed tonewFallbackSurface(), and on anyQWindowthat is used with theQRhi.A
QSurfacehas to be specified infallbackSurface. In order to prevent mistakes in threaded situations, this is never created automatically by theQRhibecause, likeQWindow, instances ofQSurfacesubclasses can often be created on the gui/main thread only.As a convenience, applications can use
newFallbackSurface()which creates and returns aQOffscreenSurfacethat is compatible with theQOpenGLContextthat is going to be created by theQRhiafterwards. Note that the ownership of the returnedQOffscreenSurfaceis transferred to the caller and theQRhiwill not destroy it.Note
With the OpenGL backend,
QRhiSwapChaincan only targetQWindowinstances that have their surface type set toOpenGLSurfaceorRasterGLSurface.Note
windowis optional. It is recommended to specify it whenever possible, in order to avoid problems on multi-adapter and multi-screen systems. Whenwindowis not set, the very firstmakeCurrent()happens withfallbackSurfacewhich may be an invisible window on some platforms (for example, Windows) and that may trigger unexpected problems in some cases.In case resource sharing with an existing
QOpenGLContextis desired,shareContextcan be set to an existingQOpenGLContext. Alternatively, Qt::AA_ShareOpenGLContexts is honored as well, when enabled.Working with existing OpenGL contexts¶
When interoperating with another graphics engine, it may be necessary to get a
QRhiinstance that uses the same OpenGL context. This can be achieved by passing a pointer to aQRhiGles2NativeHandlestocreate(). TheQRhiGles2NativeHandles::contextmust be set to a non-null value then.An alternative approach is to create a
QOpenGLContextthatshares resourceswith the other engine’s context and passing in that context viaQRhiGles2NativeHandles.The
QRhidoes not take ownership of theQOpenGLContextpassed in viaQRhiGles2NativeHandles.- PySide6.QtGui.QRhiGles2InitParams.format¶
- PySide6.QtGui.QRhiGles2InitParams.fallbackSurface¶
- PySide6.QtGui.QRhiGles2InitParams.window¶
- __init__()¶
Constructs a new
QRhiGles2InitParams.format is set to
defaultFormat().- static newFallbackSurface([format=QSurfaceFormat.defaultFormat()])¶
- Parameters:
format –
QSurfaceFormat- Return type:
Returns a new
QOffscreenSurfacethat can be used with aQRhiby passing it via aQRhiGles2InitParams.When
formatis not specified, its default value is the global default format settable viasetDefaultFormat().formatis adjusted as appropriate in order to avoid having problems afterwards due to an incompatible context and surface.Note
This function must only be called on the gui/main thread.
Note
It is the application’s responsibility to destroy the returned
QOffscreenSurfaceon the gui/main thread once the associatedQRhihas been destroyed. TheQRhiwill not destroy theQOffscreenSurface.