Loading [MathJax]/extensions/tex2jax.js
Carna  Version 3.0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Friends | List of all members
Carna::base::GLContext Class Referenceabstract

Wraps and represents an OpenGL context. More...

#include <GLContext.h>

+ Inheritance diagram for Carna::base::GLContext:

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. More...
 
const ShaderProgramshader () const
 References the shader set last. More...
 
void clearBuffers (unsigned int flags)
 Wraps glClear. Automatically enables on glDepthMask temporarily if the DEPTH_BUFFER_BIT is supplied.
 

Static Public Member Functions

static GLContextcurrent ()
 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 RenderStatecurrentRenderState () const
 References the latest render state.
 
virtual void activate () const =0
 Activates the OpenGL context represented by this object.
 

Friends

class RenderState
 

Detailed Description

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.

Author
Leonid Kostrykin
Date
22.2.15 - 15.3.15

Definition at line 62 of file GLContext.h.

Member Function Documentation

void Carna::base::GLContext::setShader ( const ShaderProgram shader)

Makes shader the current shader of the represented OpenGL context.

Precondition
isCurrent() == true
const ShaderProgram& Carna::base::GLContext::shader ( ) const

References the shader set last.

Precondition
setShader has been called previously.

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