Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QOpenGLSharedResource Class Referenceabstract

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...

#include <qopenglcontext_p.h>

+ Inheritance diagram for QOpenGLSharedResource:
+ Collaboration diagram for QOpenGLSharedResource:

Public Member Functions

 QOpenGLSharedResource (QOpenGLContextGroup *group)
 
virtual ~QOpenGLSharedResource ()=0
 
QOpenGLContextGroupgroup () const
 
void free ()
 

Protected Member Functions

virtual void invalidateResource ()=0
 
virtual void freeResource (QOpenGLContext *context)=0
 

Friends

class QOpenGLContextGroup
 
class QOpenGLContextGroupPrivate
 
class QOpenGLMultiGroupSharedResource
 

Detailed Description

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.

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.

Definition at line 39 of file qopenglcontext_p.h.

Constructor & Destructor Documentation

◆ QOpenGLSharedResource()

QOpenGLSharedResource::QOpenGLSharedResource ( QOpenGLContextGroup * group)

Definition at line 1147 of file qopenglcontext.cpp.

◆ ~QOpenGLSharedResource()

QOpenGLSharedResource::~QOpenGLSharedResource ( )
pure virtual

Definition at line 1154 of file qopenglcontext.cpp.

Member Function Documentation

◆ free()

void QOpenGLSharedResource::free ( )

Definition at line 1159 of file qopenglcontext.cpp.

References QOpenGLContext::currentContext(), and QOpenGLContext::shareGroup().

Referenced by QOpenGLMultiGroupSharedResource::~QOpenGLMultiGroupSharedResource(), QOpenGLShaderPrivate::~QOpenGLShaderPrivate(), QOpenGLShaderProgramPrivate::~QOpenGLShaderProgramPrivate(), QOpenGLTextureGlyphCache::clear(), QOpenGLShaderPrivate::deleteShader(), and QOpenGLFramebufferObjectPrivate::initDepthStencilAttachments().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ freeResource()

◆ group()

QOpenGLContextGroup * QOpenGLSharedResource::group ( ) const
inline

Definition at line 45 of file qopenglcontext_p.h.

◆ invalidateResource()

Friends And Related Symbol Documentation

◆ QOpenGLContextGroup

friend class QOpenGLContextGroup
friend

Definition at line 60 of file qopenglcontext_p.h.

◆ QOpenGLContextGroupPrivate

friend class QOpenGLContextGroupPrivate
friend

Definition at line 61 of file qopenglcontext_p.h.

◆ QOpenGLMultiGroupSharedResource

friend class QOpenGLMultiGroupSharedResource
friend

Definition at line 62 of file qopenglcontext_p.h.


The documentation for this class was generated from the following files: