12#ifndef GLCONTEXT_H_6014714286
13#define GLCONTEXT_H_6014714286
15#include <Carna/Carna.h>
68 const std::unique_ptr< Details > pimpl;
173template<
typename QGLContext,
typename QGLFormat >
193 virtual void activate()
const override;
198template<
typename QGLContext,
typename QGLFormat >
203 const QGLFormat& format = QGLContext::currentContext()->format();
204 if( format.majorVersion() < 3 || ( format.majorVersion() == 3 && format.minorVersion() < 3 ) )
206 std::stringstream
msg;
207 msg <<
"OpenGL context version " << format.majorVersion() <<
"." << format.minorVersion() <<
" is too low.";
212 CARNA_ASSERT( format.profile() != QGLFormat::NoProfile );
213 std::stringstream
msg;
214 msg <<
"Recognized OpenGL " << format.majorVersion() <<
"." << format.minorVersion() <<
" context (";
215 msg << ( format.profile() == QGLFormat::CoreProfile ?
"core" :
"compatibility" ) <<
" profile)";
221template<
typename QGLContext,
typename QGLFormat >
224 QGLFormat format = QGLFormat::defaultFormat();
225 format.setVersion( 3, 3 );
226 format.setProfile( QGLFormat::CompatibilityProfile );
231template<
typename QGLContext,
typename QGLFormat >
234 qglcontext.makeCurrent();
Defines Carna::base::CarnaException, Carna::base::AssertionFailure.
#define CARNA_ASSERT(expression)
If the given expression is false, a break point is raised in debug mode and an AssertionFailure throw...
#define CARNA_FAIL(description)
Causes a break point in debug mode and throws an AssertionFailure.
Defines Carna::base::Log.
Represents an association.
Wraps and represents an OpenGL context.
GLContext(bool isDoubleBuffered)
Instantiates GLContext that represents the current OpenGL context.
static GLContext & current()
References the current OpenGL context wrapper.
const RenderState & currentRenderState() const
References the latest render state.
void makeCurrent() const
Makes the OpenGL context represented by this object the current one.
virtual void activate() const =0
Activates the OpenGL context represented by this object.
virtual ~GLContext()
Deletes.
void popRenderState()
Restores previous render state.
void pushRenderState(const RenderState &rs)
Makes rs the current render state.
static const unsigned int DEPTH_BUFFER_BIT
Wraps GL_DEPTH_BUFFER_BIT.
void setShader(const ShaderProgram &shader)
Makes shader the current shader of the represented OpenGL context.
void clearBuffers(unsigned int flags)
Wraps glClear. Automatically enables on glDepthMask temporarily if the DEPTH_BUFFER_BIT is supplied.
const bool isDoubleBuffered
Tells whether the represented OpenGL context uses double buffering.
bool isCurrent() const
Tells whether the OpenGL context represented by this object is the current one.
const ShaderProgram & shader() const
References the shader set last.
static const unsigned int COLOR_BUFFER_BIT
Wraps GL_COLOR_BUFFER_BIT
@ debug
Indicates messages that might be of interest when searching bugs.
If you're using Qt, this class template implements the abstract GLContext class as an adapter to the ...
static QGLFormat desiredFormat()
Holds the recommended format that shall be used to create a QGLContext.
virtual void activate() const override
Activates the OpenGL context represented by this object.
QGLContextAdapter()
Creates GLContext wrapper for the current QGLContext object.
Manages the OpenGL render state.
Maintains an OpenGL shader program. Realizes the RAII-idiom.
static Log & instance()
Returns the only instance from class InstanceType.
#define NON_COPYABLE
Features class it is placed in as non-copyable.