15#ifndef GLCONTEXT_H_6014714286
16#define GLCONTEXT_H_6014714286
71 const std::unique_ptr< Details > pimpl;
175template<
typename QGLContext,
typename QGLFormat >
195 virtual void activate()
const override;
200template<
typename QGLContext,
typename QGLFormat >
205 const QGLFormat& format = QGLContext::currentContext()->format();
206 if( format.majorVersion() < 3 || ( format.majorVersion() == 3 && format.minorVersion() < 3 ) )
208 std::stringstream
msg;
209 msg <<
"OpenGL context version " << format.majorVersion() <<
"." << format.minorVersion() <<
" is too low.";
215 std::stringstream
msg;
216 msg <<
"Recognized OpenGL " << format.majorVersion() <<
"." << format.minorVersion() <<
" context (";
217 msg << ( format.profile() == QGLFormat::CoreProfile ?
"core" :
"compatibility" ) <<
" profile)";
223template<
typename QGLContext,
typename QGLFormat >
226 QGLFormat format = QGLFormat::defaultFormat();
227 format.setVersion( 3, 3 );
228 format.setProfile( QGLFormat::CompatibilityProfile );
233template<
typename QGLContext,
typename QGLFormat >
236 qglcontext.makeCurrent();
Defines LibCarna::base::LibCarnaException and LibCarna::base::AssertionFailure.
#define LIBCARNA_FAIL(description)
Causes a break point in debug mode and throws an AssertionFailure.
#define LIBCARNA_ASSERT(expression)
If the given expression is false, a break point is raised in debug mode and an AssertionFailure throw...
Contains forward-declarations.
Defines LibCarna::base::Log.
Represents an association.
Wraps and represents an OpenGL context.
void makeCurrent() const
Makes the OpenGL context represented by this object the current one.
static const unsigned int DEPTH_BUFFER_BIT
Wraps GL_DEPTH_BUFFER_BIT.
const ShaderProgram & shader() const
References the shader set last.
void popRenderState()
Restores previous render state.
void clearBuffers(unsigned int flags)
Wraps glClear. Automatically enables on glDepthMask temporarily if the DEPTH_BUFFER_BIT is supplied.
const RenderState & currentRenderState() const
References the latest render state.
virtual void activate() const =0
Activates the OpenGL context represented by this object.
void pushRenderState(const RenderState &rs)
Makes rs the current render state.
bool isCurrent() const
Tells whether the OpenGL context represented by this object is the current one.
virtual ~GLContext()
Deletes.
const bool isDoubleBuffered
Tells whether the represented OpenGL context uses double buffering.
void setShader(const ShaderProgram &shader)
Makes shader the current shader of the represented OpenGL context.
static const unsigned int COLOR_BUFFER_BIT
Wraps GL_COLOR_BUFFER_BIT
static GLContext & current()
References the current OpenGL context wrapper.
GLContext(bool isDoubleBuffered)
Instantiates GLContext that represents the current OpenGL context.
@ 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 ...
virtual void activate() const override
Activates the OpenGL context represented by this object.
QGLContextAdapter()
Creates GLContext wrapper for the current QGLContext object.
static QGLFormat desiredFormat()
Holds the recommended format that shall be used to create a QGLContext.
Manages the OpenGL render state.
Maintains an OpenGL shader program. Realizes the RAII-idiom.
static Log & instance()
Returns the only instance from class InstanceType.
Defines LibCarna::base::noncopyable and NON_COPYABLE.
#define NON_COPYABLE
Marks the class that it is placed in as non-copyable.