![]() |
Carna Version 3.3.3
|
Wraps and represents an OpenGL context. More...
#include <GLContext.h>
Public Member Functions | |
virtual | ~GLContext () |
Deletes. | |
void | makeCurrent () const |
Makes the OpenGL context represented by this object the current one. | |
bool | isCurrent () const |
Tells whether the OpenGL context represented by this object is the current one. | |
void | setShader (const ShaderProgram &shader) |
Makes shader the current shader of the represented OpenGL context. | |
const ShaderProgram & | shader () const |
References the shader set last. | |
void | clearBuffers (unsigned int flags) |
Wraps glClear . Automatically enables on glDepthMask temporarily if the DEPTH_BUFFER_BIT is supplied. | |
Static Public Member Functions | |
static GLContext & | current () |
References the current OpenGL context wrapper. | |
Public Attributes | |
const bool | isDoubleBuffered |
Tells whether the represented OpenGL context uses double buffering. | |
Static Public Attributes | |
static const unsigned int | DEPTH_BUFFER_BIT |
Wraps GL_DEPTH_BUFFER_BIT . | |
static const unsigned int | COLOR_BUFFER_BIT |
Wraps GL_COLOR_BUFFER_BIT | |
Protected Member Functions | |
GLContext (bool isDoubleBuffered) | |
Instantiates GLContext that represents the current OpenGL context. | |
void | pushRenderState (const RenderState &rs) |
Makes rs the current render state. | |
void | popRenderState () |
Restores previous render state. | |
const RenderState & | currentRenderState () const |
References the latest render state. | |
virtual void | activate () const =0 |
Activates the OpenGL context represented by this object. | |
Friends | |
class | RenderState |
Wraps and represents an OpenGL context.
This is a good explanation of the essence of OpenGL contexts:
An OpenGL context represents many things. A context stores all of the state associated with this instance of OpenGL. [...] Each context can represent a separate viewable surface, like a window in an application. Contexts can share many kinds of objects between each other. Any OpenGL object types which are not containers are sharable, as well as [...] GLSL Objects. [...] In order for any OpenGL commands to work, a context must be current; all OpenGL commands affect the state of whichever context is current. The current context is a thread-local variable, so a single process can have several threads, each of which has its own current context.
Reference: https://www.opengl.org/wiki/OpenGL_Context
Carna assumes that all OpenGL contexts within your application are capable of sharing objects. Carna does not support multi-threading environments, i.e. all Carna-related code must be run on the same thread. The states are maintained through the RenderState class.
Definition at line 62 of file GLContext.h.
Activates the OpenGL context represented by this object.
Implemented in Carna::base::QGLContextAdapter< QGLContext, QGLFormat >.
void Carna::base::GLContext::setShader | ( | const ShaderProgram & | shader | ) |
Makes shader the current shader of the represented OpenGL context.
isCurrent() == true
const ShaderProgram & Carna::base::GLContext::shader | ( | ) | const |
References the shader set last.
|
friend |
Definition at line 77 of file GLContext.h.
Wraps GL_COLOR_BUFFER_BIT
Definition at line 97 of file GLContext.h.
Wraps GL_DEPTH_BUFFER_BIT
.
Definition at line 96 of file GLContext.h.
Tells whether the represented OpenGL context uses double buffering.
Definition at line 107 of file GLContext.h.
Documentation generated by Doxygen