VVISF & VVGL
VVGL::GLContext Class Reference

GLContext is an attempt to make a platform/SDK-agnostic representation of an OpenGL context. More...

#include <GLContext.hpp>

Public Member Functions

GLContextRef newContextSharingMe () const
 Creates and returns a new OpenGL context in the same sharegroup as the receiver.
 
void makeCurrent ()
 Makes this GL context current.
 
void makeCurrentIfNotCurrent ()
 Makes this GL context current if it isn't already current.
 
void makeCurrentIfNull ()
 Makes this GL context current if no context is current.
 
bool sameShareGroupAs (const GLContextRef &inCtx)
 Returns a true if the passed context is in the same sharegroup as the receiver.
 

Public Attributes

GLVersion version = GLVersion_Unknown
 The version of OpenGL this context is using.
 

Related Functions

(Note that these are not member functions.)

using GLContextRef = shared_ptr< GLContext >
 A GLContextRef is a shared pointer around a GLContext.
 
QSurfaceFormat CreateDefaultSurfaceFormat ()
 Creates a surface format describing the default OpenGL surface settings for this platform.
 
QSurfaceFormat CreateCompatibilityGLSurfaceFormat ()
 Creates a surface format describing the compatibility profile of OpenGL for this platform.
 
QSurfaceFormat CreateGL3SurfaceFormat ()
 Creates a surface format describing the OpenGL 3 profile for this platform.
 
QSurfaceFormat CreateGL4SurfaceFormat ()
 Creates a surface format describing the OpenGL 4 profile for this platform.
 
GLContextRef CreateGLContextRefUsing (QSurface *inTargetSurface, QOpenGLContext *inCtx, QSurfaceFormat inSfcFmt=CreateDefaultSurfaceFormat())
 Doesn't create any GL resources, just makes a new GLContext instance using the passed resources. More...
 
GLContextRef CreateNewGLContextRef (QSurface *inTargetSurface, QOpenGLContext *inShareCtx, QSurfaceFormat inSfcFmt=CreateDefaultSurfaceFormat())
 Creates a new OpenGL context and GLContext instance. More...
 
GLContextRef CreateNewGLContextRef ()
 Creates a generic OpenGL context and GLContext instance using whatever the default settings are for this platform and SDK.
 

Detailed Description

GLContext is an attempt to make a platform/SDK-agnostic representation of an OpenGL context.

GLContext is a OpenGL context- this class wraps up whatever the native object is for whatever platform/SDK you're compiling VVGL against, and presents a single standard interface across all platforms for the rest of VVGL and any libs that derive from it. You can create a GLContext around an existing platform-specific OpenGL context- which makes integration with existing codebases easy- or you can also create new OpenGL contexts by making a new instance of GLContext or using the newContextSharingMe() member function of an existing context. Has explicit support for sharing of multiple contexts so resources (textures, models, etc) can be shared between contexts.

Notes on use:

  • You should strive whenever possible to work with GLContextRef instead of GLContext.
  • If you want to create a GLContext, you should try using one of the non-member creation functions listed on this page. These functions return a GLContextRef instead of just a GLContext, and their function names are slightly more verbose and descriptive than GLContext's constructors.
  • The specific constructor (or create functions) for creating a GLContext is going to depend on the SDK you're working with, because they generally require some sort of platform- or SDK-specific object or pointer to a native GL context.

Friends And Related Function Documentation

◆ CreateGLContextRefUsing()

GLContextRef CreateGLContextRefUsing ( QSurface *  inTargetSurface,
QOpenGLContext *  inCtx,
QSurfaceFormat  inSfcFmt = CreateDefaultSurfaceFormat() 
)
related

Doesn't create any GL resources, just makes a new GLContext instance using the passed resources.

Parameters
inTargetSurfaceIf null, a QOffscreenSurface will be created. If non-null (a widget or window or etc), we just store a weak ref to the passed surface.
inCtxMust be non-null. A weak ref is made to this context- the GLContext instance that is created is basically just a wrapper around this context.
inSfcFmtThe surface format describes what kind of OpenGL environment you want to work with. The QSurfaceFormat can be created using one of the Create****SurfaceFormat() functions listed in this document.

◆ CreateNewGLContextRef()

GLContextRef CreateNewGLContextRef ( QSurface *  inTargetSurface,
QOpenGLContext *  inShareCtx,
QSurfaceFormat  inSfcFmt = CreateDefaultSurfaceFormat() 
)
related

Creates a new OpenGL context and GLContext instance.

Parameters
inTargetSurfaceIf null, a QOffscreenSurface will be created. If non-null (a widget or window or etc), we just store a weak ref to the passed surface.
inShareCtxThe OpenGL context that gets created will be in the same sharegroup as this context.
inSfcFmtThe surface format describes what kind of OpenGL environment you want to work with. The QSurfaceFormat can be created using one of the Create****SurfaceFormat() functions listed in this document.

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