Commit d25b9f6a authored by Robert Menzel's avatar Robert Menzel

cleanups and documentation

parent fb78c669
......@@ -137,14 +137,18 @@ namespace ACGL
/*
* This should get called as soon as a valid OpenGL context exists,
* it will init glew (if used).
* it will init glew (if used) or the internal GL function loader.
* Call this before calling any OpenGL functions or OpenGL related
* ACGL stuff.
*
* Returns false if a critical error occured, in that case the ACGL behavior is
* not defined.
*
* parameter forDebugging: if true, register a debug callback for OpenGL and simulate
* a debug context (slow) in case the application is not running in a native debug
* context.
*/
bool init();
bool init( bool forceDebuggingContext = true );
}
......
......@@ -22,6 +22,7 @@ const char *debugTypeName( GLenum _type );
const char *debugSeverityName( GLenum _type );
//! tries to register the default debug callback:
//! applications can register alternative callbacks with glDebugMessageCallback !
void ACGLRegisterDefaultDebugCallback();
//! default debug callback
......
......@@ -198,15 +198,8 @@ private:
// ===================================================================================================== \/
public:
//! Bind this VAO
//! If error checking is set to common or higher, some consistancy checks are made
#ifdef ACGL_CHECK_COMMON_GL_ERRORS
//! some consistancy checks are made
void bind() const;
#else
inline void bind() const
{
glBindVertexArray( mObjectName );
}
#endif
//! Nothing has to be prepared for a render call
inline void render (void)
......
......@@ -161,6 +161,11 @@ const GLubyte* acglErrorString( GLenum _errorCode );
GLenum openGLError_( const char *_fileName, const unsigned long _lineNumber );
/*
* NOTE: Explicit error checks are not needed anymore on desktop systems! Use KHR_debug
* callback instead (ACGL registers a default callback automatically).
*
*
*
* Inside of ACGL we distinguish between rare, common and critical errors. Each kind can be
* switched off which turns the function into nothing after compiler optimization. If an
* error check is turned off it will always behave as if there was no error, even if there
......
......@@ -13,27 +13,12 @@
namespace ACGL
{
bool init()
bool init( bool forceDebuggingContext )
{
Utils::debug() << "ACGL was compiled for "
#ifdef ACGL_DEBUG
<< "debug" << std::endl;
#else
<< "release" << std::endl;
Utils::debug() << "ACGL was compiled for debug" << std::endl;
#endif
Utils::debug() << "OpenGL error checking is set to "
#if defined( ACGL_CHECK_NO_GL_ERRORS )
<< "NO checks" << std::endl;
#elif defined( ACGL_CHECK_RARE_GL_ERRORS )
<< "check a lot (for debugging)" << std::endl;
#elif defined( ACGL_CHECK_COMMON_GL_ERRORS )
<< "normal" << std::endl;
#elif defined( ACGL_CHECK_CRITICAL_GL_ERRORS )
<< "only most critical checks" << std::endl;
#endif
//
// init GLEW or own extension loader, do nothing on ES
//
......@@ -42,15 +27,15 @@ bool init()
glewExperimental = GL_TRUE;
# endif
GLenum errorCode = glewInit();
if ((errorCode != GLEW_OK) || (openGLCriticalErrorOccured())) {
if ((errorCode != GLEW_OK) || (openGLErrorOccured())) {
Utils::error() << "could not init GLEW!" << std::endl;
#ifdef ACGL_OPENGL_PROFILE_CORE
Utils::error() << "Make sure your version of GLEW is compatible with core contexts" << std::endl;
Utils::error() << "Make sure your version of GLEW is compatible with core contexts!" << std::endl;
#endif
return false;
}
#elif defined( ACGL_EXTENSION_LOADER_GLLOADGEN )
int loaded = ogl_LoadFunctionsForDebug( GL_TRUE, GL_TRUE );
int loaded = ogl_LoadFunctionsForDebug( GL_TRUE, forceDebuggingContext );
if (loaded == ogl_LOAD_FAILED)
{
Utils::error() << "could not load OpenGL functions!" << std::endl;
......
......@@ -56,7 +56,6 @@ SharedShaderProgram ShaderProgramCreator::create()
}
for (std::vector<std::string>::size_type i = 0; i < numberOfFiles; ++i) {
# ifdef ACGL_CHECK_CRITICAL_GL_ERRORS
// check for problems:
if ( mShaderType[i] == GL_INVALID_VALUE ) {
......@@ -79,7 +78,6 @@ SharedShaderProgram ShaderProgramCreator::create()
Utils::error() << "file " << mFileNames[i] << " ignored, hardware does not support tessellation shader" << std::endl;
mShaderType[i] = GL_INVALID_VALUE;
}
# endif // critical checks
// attach shader
if ( mShaderType[i] != GL_INVALID_VALUE ) {
......@@ -87,9 +85,7 @@ SharedShaderProgram ShaderProgramCreator::create()
if ( shader ) {
shaderProgram->attachShader( shader );
} else {
# ifdef ACGL_CHECK_CRITICAL_GL_ERRORS
Utils::error() << "could not attach shader " << mFileNames[i] << std::endl;
# endif // critical checks
}
}
}
......
......@@ -55,7 +55,7 @@ void ACGLRegisterDefaultDebugCallback()
GLint v;
glGetIntegerv( GL_CONTEXT_FLAGS, &v );
if ((v & GL_CONTEXT_FLAG_DEBUG_BIT) != 0) {
debug() << "context was created with KHR_debug flag" << endl;
debug() << "context was created with KHR_debug flag, register callback" << endl;
} else {
debug() << "context was created WITHOUT KHR_debug flag - registering a debug callback is possible but might not result in getting called even if errors occur!" << endl;
}
......
......@@ -17,7 +17,6 @@ bool ShaderProgram::link() const
{
glLinkProgram(mObjectName);
#ifdef ACGL_CHECK_CRITICAL_GL_ERRORS
// check for program link errors:
GLint programError;
glGetProgramiv(mObjectName, GL_LINK_STATUS, &programError);
......@@ -39,7 +38,6 @@ bool ShaderProgram::link() const
delete[] pInfo;
return (programError == GL_TRUE); // if the log contains only warnings we return true
}
#endif
return true;
}
......
......@@ -24,7 +24,6 @@ VertexArrayObject::VertexArrayObject( GLenum _mode ) :
mAttributes.resize( maxAttributes ); // reserve probably 16 slots, the size() can now be used to query the MAX_VERTEX_ATTRIBS
}
#ifdef ACGL_CHECK_COMMON_GL_ERRORS
void VertexArrayObject::bind() const
{
glBindVertexArray( mObjectName );
......@@ -45,7 +44,6 @@ void VertexArrayObject::bind() const
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, myEAB);
}
}
#endif
void VertexArrayObject::attachElementArrayBuffer( const ConstSharedElementArrayBuffer& _elementArrayBuffer )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment