Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QOpenGLContext Class Reference

\inmodule QtGui More...

#include <qopenglcontext.h>

+ Inheritance diagram for QOpenGLContext:
+ Collaboration diagram for QOpenGLContext:

Public Types

enum  OpenGLModuleType { LibGL , LibGLES }
 This enum defines the type of the underlying OpenGL implementation. More...
 

Signals

void 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.
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked.
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 This signal is emitted after the object's name has been changed.
 

Public Member Functions

 QOpenGLContext (QObject *parent=nullptr)
 Creates a new OpenGL context instance with parent object parent.
 
 ~QOpenGLContext ()
 Destroys the QOpenGLContext object.
 
void setFormat (const QSurfaceFormat &format)
 Sets the format the OpenGL context should be compatible with.
 
void setShareContext (QOpenGLContext *shareContext)
 Makes this context share textures, shaders, and other OpenGL resources with shareContext.
 
void setScreen (QScreen *screen)
 Sets the screen the OpenGL context should be valid for.
 
bool create ()
 Attempts to create the OpenGL context with the current configuration.
 
bool isValid () const
 Returns if this context is valid, i.e.
 
QSurfaceFormat format () const
 Returns the format of the underlying platform context, if create() has been called.
 
QOpenGLContextshareContext () const
 Returns the share context this context was created with.
 
QOpenGLContextGroupshareGroup () const
 Returns the share group this context belongs to.
 
QScreenscreen () const
 Returns the screen the context was created for.
 
GLuint defaultFramebufferObject () const
 Call this to get the default framebuffer object for the current surface.
 
bool makeCurrent (QSurface *surface)
 Makes the context current in the current thread, against the given surface.
 
void doneCurrent ()
 Convenience function for calling makeCurrent with a 0 surface.
 
void swapBuffers (QSurface *surface)
 Swap the back and front buffers of surface.
 
QFunctionPointer getProcAddress (const QByteArray &procName) const
 Resolves the function pointer to an OpenGL extension function, identified by procName.
 
QFunctionPointer getProcAddress (const char *procName) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QSurfacesurface () const
 Returns the surface the context has been made current with.
 
QPlatformOpenGLContexthandle () const
 Returns the underlying platform context.
 
QPlatformOpenGLContextshareHandle () const
 Returns the underlying platform context with which this context is sharing.
 
QOpenGLFunctionsfunctions () const
 Get the QOpenGLFunctions instance for this context.
 
QOpenGLExtraFunctionsextraFunctions () const
 Get the QOpenGLExtraFunctions instance for this context.
 
QSet< QByteArrayextensions () const
 Returns the set of OpenGL extensions supported by this context.
 
bool hasExtension (const QByteArray &extension) const
 Returns true if this OpenGL context supports the specified OpenGL extension, false otherwise.
 
bool isOpenGLES () const
 Returns true if the context is an OpenGL ES context.
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 Constructs an object with parent object parent.
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects.
 
virtual bool event (QEvent *event)
 This virtual function receives events to an object and should return true if the event e was recognized and processed.
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 Filters events if this object has been installed as an event filter for the watched object.
 
QString objectName () const
 
Q_WEAK_OVERLOAD void setObjectName (const QString &name)
 Sets the object's name to name.
 
void setObjectName (QAnyStringView name)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false.
 
bool isWindowType () const
 Returns true if the object is a window; otherwise returns false.
 
bool isQuickItemType () const
 Returns true if the object is a QQuickItem; otherwise returns false.
 
bool signalsBlocked () const noexcept
 Returns true if signals are blocked; otherwise returns false.
 
bool blockSignals (bool b) noexcept
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it).
 
QThreadthread () const
 Returns the thread in which the object lives.
 
bool moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL)
 Changes the thread affinity for this object and its children and returns true on success.
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds.
 
int startTimer (std::chrono::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 Kills the timer with timer identifier, id.
 
void killTimer (Qt::TimerId id)
 
template<typename T >
findChild (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object.
 
template<typename T >
QList< T > findChildren (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects.
 
template<typename T >
findChild (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename T >
QList< T > findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const QObjectListchildren () const
 Returns a list of child objects.
 
void setParent (QObject *parent)
 Makes the object a child of parent.
 
void installEventFilter (QObject *filterObj)
 Installs an event filter filterObj on this object.
 
void removeEventFilter (QObject *obj)
 Removes an event filter object obj from this object.
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 Dumps a tree of children to the debug output.
 
void dumpObjectInfo () const
 Dumps information about signal connections, etc.
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value.
 
bool setProperty (const char *name, QVariant &&value)
 
QVariant property (const char *name) const
 Returns the value of the object's name property.
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 Returns a pointer to the parent object.
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false.
 

Static Public Member Functions

static QOpenGLContextcurrentContext ()
 Returns the last context which called makeCurrent in the current thread, or \nullptr, if no context is current.
 
static bool areSharing (QOpenGLContext *first, QOpenGLContext *second)
 Returns true if the first and second contexts are sharing OpenGL resources.
 
static OpenGLModuleType openGLModuleType ()
 Returns the underlying OpenGL implementation type.
 
static bool supportsThreadedOpenGL ()
 Returns true if the platform supports OpenGL rendering outside the main (gui) thread.
 
static QOpenGLContextglobalShareContext ()
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 \threadsafe
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 \threadsafe
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 Disconnect a connection.
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 

Friends

class QOpenGLContextResourceBase
 
class QOpenGLPaintDevice
 
class QOpenGLGlyphTexture
 
class QOpenGLTextureGlyphCache
 
class QOpenGLEngineShaderManager
 
class QOpenGLFramebufferObject
 
class QOpenGLFramebufferObjectPrivate
 
class QOpenGL2PaintEngineEx
 
class QOpenGL2PaintEngineExPrivate
 
class QSGDistanceFieldGlyphCache
 
class QWidgetPrivate
 
class QAbstractOpenGLFunctionsPrivate
 
class QOpenGLTexturePrivate
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 \threadsafe
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr.
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal.
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 This event handler can be reimplemented in a subclass to receive timer events for the object.
 
virtual void childEvent (QChildEvent *event)
 This event handler can be reimplemented in a subclass to receive child events.
 
virtual void customEvent (QEvent *event)
 This event handler can be reimplemented in a subclass to receive custom events.
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Properties inherited from QObject
QString objectName
 the name of this object
 

Detailed Description

\inmodule QtGui

Since
5.0

The QOpenGLContext class represents a native OpenGL context, enabling OpenGL rendering on a QSurface.

QOpenGLContext represents the OpenGL state of an underlying OpenGL context. To set up a context, set its screen and format such that they match those of the surface or surfaces with which the context is meant to be used, if necessary make it share resources with other contexts with setShareContext(), and finally call create(). Use the return value or isValid() to check if the context was successfully initialized.

A context can be made current against a given surface by calling makeCurrent(). When OpenGL rendering is done, call swapBuffers() to swap the front and back buffers of the surface, so that the newly rendered content becomes visible. To be able to support certain platforms, QOpenGLContext requires that you call makeCurrent() again before starting rendering a new frame, after calling swapBuffers().

If the context is temporarily not needed, such as when the application is not rendering, it can be useful to delete it in order to free resources. You can connect to the aboutToBeDestroyed() signal to clean up any resources that have been allocated with different ownership from the QOpenGLContext itself.

Once a QOpenGLContext has been made current, you can render to it in a platform independent way by using Qt's OpenGL enablers such as QOpenGLFunctions, QOpenGLBuffer, QOpenGLShaderProgram, and QOpenGLFramebufferObject. It is also possible to use the platform's OpenGL API directly, without using the Qt enablers, although potentially at the cost of portability. The latter is necessary when wanting to use OpenGL 1.x or OpenGL ES 1.x.

For more information about the OpenGL API, refer to the official \l{http://www.opengl.org}{OpenGL documentation}.

For an example of how to use QOpenGLContext see the \l{OpenGL Window Example}{OpenGL Window} example.

Definition at line 66 of file qopenglcontext.h.

Member Enumeration Documentation

◆ OpenGLModuleType

This enum defines the type of the underlying OpenGL implementation.

\value LibGL OpenGL \value LibGLES OpenGL ES 2.0 or higher

Since
5.3
Enumerator
LibGL 
LibGLES 

Definition at line 109 of file qopenglcontext.h.

Constructor & Destructor Documentation

◆ QOpenGLContext()

QOpenGLContext::QOpenGLContext ( QObject * parent = nullptr)
explicit

Creates a new OpenGL context instance with parent object parent.

Before it can be used you need to set the proper format and call create().

See also
create(), makeCurrent()

Definition at line 276 of file qopenglcontext.cpp.

◆ ~QOpenGLContext()

QOpenGLContext::~QOpenGLContext ( )

Destroys the QOpenGLContext object.

If this is the current context for the thread, doneCurrent() is also called.

Definition at line 486 of file qopenglcontext.cpp.

Member Function Documentation

◆ aboutToBeDestroyed

void QOpenGLContext::aboutToBeDestroyed ( )
signal

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.

Note
In Qt for Python, this signal will not be received when emitted from the destructor of QOpenGLWidget or QOpenGLWindow due to the Python instance already being destroyed. We recommend doing cleanups in QWidget::hideEvent() instead.

◆ areSharing()

bool QOpenGLContext::areSharing ( QOpenGLContext * first,
QOpenGLContext * second )
static

Returns true if the first and second contexts are sharing OpenGL resources.

Definition at line 239 of file qopenglcontext.cpp.

◆ create()

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(), format()

Definition at line 368 of file qopenglcontext.cpp.

◆ currentContext()

QOpenGLContext * QOpenGLContext::currentContext ( )
static

Returns the last context which called makeCurrent in the current thread, or \nullptr, if no context is current.

Definition at line 228 of file qopenglcontext.cpp.

◆ defaultFramebufferObject()

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

Definition at line 619 of file qopenglcontext.cpp.

◆ doneCurrent()

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(), currentContext()

Definition at line 743 of file qopenglcontext.cpp.

◆ extensions()

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()

Definition at line 571 of file qopenglcontext.cpp.

◆ extraFunctions()

QOpenGLExtraFunctions * QOpenGLContext::extraFunctions ( ) const

Get the QOpenGLExtraFunctions instance for this context.

QOpenGLContext offers this as a convenient way to access QOpenGLExtraFunctions without having to manage it manually.

The context or a sharing context must be current.

The returned QOpenGLExtraFunctions instance is ready to be used and it does not need initializeOpenGLFunctions() to be called.

Note
QOpenGLExtraFunctions contains functionality that is not guaranteed to be available at runtime. Runtime availability depends on the platform, graphics driver, and the OpenGL version requested by the application.
See also
QOpenGLFunctions, QOpenGLExtraFunctions

Definition at line 559 of file qopenglcontext.cpp.

◆ format()

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.

Definition at line 847 of file qopenglcontext.cpp.

◆ functions()

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.

Definition at line 534 of file qopenglcontext.cpp.

◆ getProcAddress() [1/2]

QFunctionPointer QOpenGLContext::getProcAddress ( const char * procName) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.8

Definition at line 820 of file qopenglcontext.cpp.

◆ getProcAddress() [2/2]

QFunctionPointer QOpenGLContext::getProcAddress ( const QByteArray & procName) const

Resolves the function pointer to an OpenGL extension function, identified by procName.

Returns \nullptr if no such function can be found.

Definition at line 811 of file qopenglcontext.cpp.

◆ globalShareContext()

QOpenGLContext * QOpenGLContext::globalShareContext ( )
static
Since
5.5

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.
See also
Qt::AA_ShareOpenGLContexts, setShareContext(), makeCurrent()

Definition at line 972 of file qopenglcontext.cpp.

◆ handle()

QPlatformOpenGLContext * QOpenGLContext::handle ( ) const

Returns the underlying platform context.

Definition at line 249 of file qopenglcontext.cpp.

◆ hasExtension()

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()

Definition at line 590 of file qopenglcontext.cpp.

◆ isOpenGLES()

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

See also
create(), format(), setFormat()
Since
5.3

Definition at line 933 of file qopenglcontext.cpp.

◆ isValid()

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 \l{QSurfaceFormat::ResetNotification}{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()

Definition at line 517 of file qopenglcontext.cpp.

◆ makeCurrent()

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 \l{QObject#Thread Affinity}{QObject thread affinity} documentation.

See also
functions(), doneCurrent(), Qt::AA_DontCheckOpenGLContextThreadAffinity

Definition at line 657 of file qopenglcontext.cpp.

◆ openGLModuleType()

QOpenGLContext::OpenGLModuleType QOpenGLContext::openGLModuleType ( )
static

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().
This function requires that the QGuiApplication instance is already created.
Since
5.3

Definition at line 911 of file qopenglcontext.cpp.

◆ screen()

QScreen * QOpenGLContext::screen ( ) const

Returns the screen the context was created for.

Definition at line 879 of file qopenglcontext.cpp.

◆ setFormat()

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.

Definition at line 292 of file qopenglcontext.cpp.

◆ setScreen()

void QOpenGLContext::setScreen ( QScreen * screen)

Sets the screen the OpenGL context should be valid for.

You need to call create() before it takes effect.

Definition at line 312 of file qopenglcontext.cpp.

◆ setShareContext()

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.

Definition at line 302 of file qopenglcontext.cpp.

◆ shareContext()

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.

Definition at line 870 of file qopenglcontext.cpp.

◆ shareGroup()

QOpenGLContextGroup * QOpenGLContext::shareGroup ( ) const

Returns the share group this context belongs to.

Definition at line 858 of file qopenglcontext.cpp.

◆ shareHandle()

QPlatformOpenGLContext * QOpenGLContext::shareHandle ( ) const

Returns the underlying platform context with which this context is sharing.

Definition at line 261 of file qopenglcontext.cpp.

◆ supportsThreadedOpenGL()

bool QOpenGLContext::supportsThreadedOpenGL ( )
static

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.

Since
5.5

Definition at line 947 of file qopenglcontext.cpp.

◆ surface()

QSurface * QOpenGLContext::surface ( ) const

Returns the surface the context has been made current with.

This is the surface passed as an argument to makeCurrent().

Definition at line 763 of file qopenglcontext.cpp.

◆ swapBuffers()

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.

Definition at line 777 of file qopenglcontext.cpp.

Friends And Related Symbol Documentation

◆ QAbstractOpenGLFunctionsPrivate

friend class QAbstractOpenGLFunctionsPrivate
friend

Definition at line 138 of file qopenglcontext.h.

◆ QOpenGL2PaintEngineEx

friend class QOpenGL2PaintEngineEx
friend

Definition at line 134 of file qopenglcontext.h.

◆ QOpenGL2PaintEngineExPrivate

friend class QOpenGL2PaintEngineExPrivate
friend

Definition at line 135 of file qopenglcontext.h.

◆ QOpenGLContextResourceBase

friend class QOpenGLContextResourceBase
friend

Definition at line 127 of file qopenglcontext.h.

◆ QOpenGLEngineShaderManager

friend class QOpenGLEngineShaderManager
friend

Definition at line 131 of file qopenglcontext.h.

◆ QOpenGLFramebufferObject

friend class QOpenGLFramebufferObject
friend

Definition at line 132 of file qopenglcontext.h.

◆ QOpenGLFramebufferObjectPrivate

friend class QOpenGLFramebufferObjectPrivate
friend

Definition at line 133 of file qopenglcontext.h.

◆ QOpenGLGlyphTexture

friend class QOpenGLGlyphTexture
friend

Definition at line 129 of file qopenglcontext.h.

◆ QOpenGLPaintDevice

friend class QOpenGLPaintDevice
friend

Definition at line 128 of file qopenglcontext.h.

◆ QOpenGLTextureGlyphCache

friend class QOpenGLTextureGlyphCache
friend

Definition at line 130 of file qopenglcontext.h.

◆ QOpenGLTexturePrivate

friend class QOpenGLTexturePrivate
friend

Definition at line 139 of file qopenglcontext.h.

◆ QSGDistanceFieldGlyphCache

friend class QSGDistanceFieldGlyphCache
friend

Definition at line 136 of file qopenglcontext.h.

◆ QWidgetPrivate

friend class QWidgetPrivate
friend

Definition at line 137 of file qopenglcontext.h.


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