12 #ifndef GLCONTEXT_H_6014714286 13 #define GLCONTEXT_H_6014714286 15 #include <Carna/Carna.h> 68 const std::unique_ptr< Details > pimpl;
75 explicit GLContext(
bool isDoubleBuffered );
87 void popRenderState();
117 void makeCurrent()
const;
123 bool isCurrent()
const;
141 void clearBuffers(
unsigned int flags );
148 virtual void activate()
const = 0;
173 template<
typename QGLContext,
typename QGLFormat >
177 QGLContext& qglcontext;
189 static QGLFormat desiredFormat();
193 virtual void activate()
const override;
198 template<
typename QGLContext,
typename QGLFormat >
200 :
GLContext( QGLContext::currentContext()->format().doubleBuffer() )
201 , qglcontext( const_cast< QGLContext& >( *QGLContext::currentContext() ) )
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)";
221 template<
typename QGLContext,
typename QGLFormat >
224 QGLFormat format = QGLFormat::defaultFormat();
225 format.setVersion( 3, 3 );
226 format.setProfile( QGLFormat::CompatibilityProfile );
231 template<
typename QGLContext,
typename QGLFormat >
234 qglcontext.makeCurrent();
243 #endif // GLCONTEXT_H_6014714286 QGLContextAdapter()
Creates GLContext wrapper for the current QGLContext object.
Manages the OpenGL render state.
static const unsigned int COLOR_BUFFER_BIT
Wraps GL_COLOR_BUFFER_BIT
Indicates messages that might be of interest when searching bugs.
virtual void activate() const override
Activates the OpenGL context represented by this object.
static QGLFormat desiredFormat()
Holds the recommended format that shall be used to create a QGLContext.
#define CARNA_FAIL(description)
Causes a break point in debug mode and throws an AssertionFailure.
Defines Carna::base::Log.
Maintains an OpenGL shader program. Realizes the RAII-idiom.
static Log & instance()
Returns the only instance from class InstanceType.
const bool isDoubleBuffered
Tells whether the represented OpenGL context uses double buffering.
If you're using Qt, this class template implements the abstract GLContext class as an adapter to the ...
static const unsigned int DEPTH_BUFFER_BIT
Wraps GL_DEPTH_BUFFER_BIT.
Defines Carna::base::CarnaException, Carna::base::AssertionFailure.
Wraps and represents an OpenGL context.
void record(Severity severity, const std::string &entry) const
Instructs current writer to write entry with severity.
#define CARNA_ASSERT(expression)
If the given expression is false, a break point is raised in debug mode and an AssertionFailure throw...
#define NON_COPYABLE
Features class it is placed in as non-copyable.