QOpenGLSharedResource Class
The QOpenGLSharedResource class is used to keep track of resources that are shared between OpenGL contexts (like textures, framebuffer objects, shader programs, etc), and clean them up in a safe way when they're no longer needed. \inmodule
QtGui. More...
Header: | #include <QOpenGLSharedResource> |
Inherited By: |
Detailed Description
\internal
\since
5.0
The QOpenGLSharedResource instance should never be deleted, instead free() should be called when it's no longer needed. Thus it will be put on a queue and freed at an appropriate time (when a context in the share group becomes current).
The sub-class needs to implement two pure virtual functions. The first, freeResource() must be implemented to actually do the freeing, for example call glDeleteTextures() on a texture id. Qt makes sure a valid context in the resource's share group is current at the time. The other, invalidateResource(), is called by Qt in the circumstance when the last context in the share group is destroyed before free() has been called. The implementation of invalidateResource() should set any identifiers to 0 or set a flag to prevent them from being used later on.