PySide6.QtGui.QOffscreenSurface¶
- class QOffscreenSurface¶
- The - QOffscreenSurfaceclass represents an offscreen surface in the underlying platform. More…- Synopsis¶- Methods¶- def - __init__()
- def - create()
- def - destroy()
- def - isValid()
- def - screen()
- def - setFormat()
- def - setScreen()
 - Signals¶- def - screenChanged()
 - 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¶- QOffscreenSurfaceis intended to be used with- QOpenGLContextto allow rendering with OpenGL in an arbitrary thread without the need to create a- QWindow.- Even though the surface is typically renderable, the surface’s pixels are not accessible. - QOffscreenSurfaceshould only be used to create OpenGL resources such as textures or framebuffer objects.- An application will typically use - QOffscreenSurfaceto perform some time-consuming tasks in a separate thread in order to avoid stalling the main rendering thread. Resources created in the- QOffscreenSurface‘s context can be shared with the main OpenGL context. Some common use cases are asynchronous texture uploads or rendering into a QOpenGLFramebufferObject.- How the offscreen surface is implemented depends on the underlying platform, but it will typically use a pixel buffer (pbuffer). If the platform doesn’t implement or support offscreen surfaces, - QOffscreenSurfacewill use an invisible- QWindowinternally.- Note - Due to the fact that - QOffscreenSurfaceis backed by a- QWindowon some platforms, cross-platform applications must ensure that- create()is only called on the main (GUI) thread. The- QOffscreenSurfaceis then safe to be used with- makeCurrent()on other threads, but the initialization and destruction must always happen on the main (GUI) thread.- Note - In order to create an offscreen surface that is guaranteed to be compatible with a given context and window, make sure to set the format to the context’s or the window’s actual format, that is, the - QSurfaceFormatreturned from- format()or- format()after the context or window has been created. Passing the format returned from- requestedFormat()to- setFormat()may result in an incompatible offscreen surface since the underlying windowing system interface may offer a different set of configurations for window and pbuffer surfaces.- Note - Some platforms may utilize a surfaceless context extension (for example EGL_KHR_surfaceless_context) when available. In this case there will be no underlying native surface. For the use cases of - QOffscreenSurface(rendering to FBOs, texture upload) this is not a problem.- Creates an offscreen surface for the - targetScreenwith the given- parent.- The underlying platform surface is not created until - create()is called.- See also - create()¶
 - Allocates the platform resources associated with the offscreen surface. - It is at this point that the surface format set using - setFormat()gets resolved into an actual native surface.- Call - destroy()to free the platform resources if necessary.- destroy()¶
 - Releases the native platform resources associated with this offscreen surface. - See also - isValid()¶
- Return type:
- bool 
 
 - Returns - trueif this offscreen surface is valid; otherwise returns- false.- The offscreen surface is valid if the platform resources have been successfully allocated. - See also - requestedFormat()¶
- Return type:
 
 - Returns the requested surfaceformat of this offscreen surface. - If the requested format was not supported by the platform implementation, the requestedFormat will differ from the actual offscreen surface format. - This is the value set with - setFormat().- See also - setFormat()- format()- resolveInterface(name, revision)¶
- Parameters:
- name – str 
- revision – int 
 
- Return type:
- void
 
 - Returns the screen to which the offscreen surface is connected. - See also - This signal is emitted when an offscreen surface’s - screenchanges, either by being set explicitly with- setScreen(), or automatically when the window’s screen is removed.- setFormat(format)¶
- Parameters:
- format – - QSurfaceFormat
 
 - Sets the offscreen surface - format.- The surface format will be resolved in the - create()function. Calling this function after- create()will not re-resolve the surface format of the native surface.- Sets the screen to which the offscreen surface is connected. - If the offscreen surface has been created, it will be recreated on the - newScreen.- See also