Skip to content

Commit

Permalink
added CHECKGLERROR define in gltools/misc
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoerner committed May 15, 2012
1 parent 5287371 commit 9bb841d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
40 changes: 40 additions & 0 deletions gltools/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "gl.h"

#include <iostream>

namespace base
{
//
Expand Down Expand Up @@ -132,4 +134,42 @@ namespace base
glEnd();
}
}



std::string glErrorString( int glErrorCode )
{
switch(glErrorCode)
{
case GL_NO_ERROR:
return "No error has been recorded.";break;
case GL_INVALID_ENUM:
return "An unacceptable value is specified for an enumerated argument.";break;
case GL_INVALID_VALUE:
return "A numeric argument is out of range.";break;
case GL_INVALID_OPERATION:
return "The specified operation is not allowed in the current state.";break;
case GL_STACK_OVERFLOW:
return "This command would cause a stack overflow.";break;
case GL_STACK_UNDERFLOW:
return "This command would cause a stack underflow.";break;
case GL_OUT_OF_MEMORY:
return "There is not enough memory left to execute the command.";break;
case GL_TABLE_TOO_LARGE:
return "GL_TABLE_TOO_LARGE";break;
default:
return "";
};
return "";
}
bool checkGlError(const char *file, int line)
{
GLenum err = glGetError();
if (err != GL_NO_ERROR)
{
std::cerr << "OpenGL Error at " << file << " line " << line << ":" << glErrorString(err) << std::endl;
return true;
}
return false;
}
}
7 changes: 5 additions & 2 deletions gltools/misc.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#pragma once

#include <string>
#include <math/Math.h>


#define CHECKGLERROR() checkGlError(__FILE__, __LINE__)

namespace base
{
void drawGrid( bool axes = true ); ///< draw a orientation grid identical to the ones used in popular dcc apps
void drawTransform( const math::Matrix44f &tm ); ///< draw orientation vectors for given transform
void headLight(); ///< sets light0 parameters accordingly

std::string glErrorString( int glErrorCode );
bool checkGlError(const char *file, int line); // returns true if there was an error
}


Expand Down

0 comments on commit 9bb841d

Please sign in to comment.