Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SDL2/SDL.h>
- #include <gl.hpp>
- void gl::errClear(){
- while(glGetError() != GL_NO_ERROR);
- }
- const char* gl::errStr(Uint32 errorCode){
- #if defined(_DEBUG)
- switch(errorCode){
- case GL_NO_ERROR : return "GL_NO_ERROR";
- case GL_INVALID_ENUM : return "GL_INVALID_ENUM";
- case GL_INVALID_VALUE : return "GL_INVALID_VALUE";
- case GL_INVALID_OPERATION : return "GL_INVALID_OPERATION";
- case GL_INVALID_FRAMEBUFFER_OPERATION: return "GL_INVALID_FRAMEBUFFER_OPERATION";
- case GL_OUT_OF_MEMORY : return "GL_OUT_OF_MEMORY";
- case GL_STACK_UNDERFLOW : return "GL_STACK_UNDERFLOW";
- case GL_STACK_OVERFLOW : return "GL_STACK_OVERFLOW";
- default: return "(unknown error code)"; //should be impossible
- };
- #else
- return "!defined(_DEBUG)";
- #endif
- }
- #define NO_INFO "\b\b\b\b\b\b"
- Uint32 gl::errLog(int lineNumber, Uint32 errorCode){
- if(errorCode == GL_NO_ERROR) errorCode = glGetError();
- #if defined(_DEBUG)
- if(errorCode == GL_NO_ERROR) return errorCode;
- if(lineNumber >= 0){
- SDL_Log(NO_INFO" Line %4i: %s (0x%08X)",
- lineNumber, gl::errStr(errorCode), errorCode);
- } else if(lineNumber == -1){
- SDL_Log(NO_INFO" %s (0x%08X)", gl::errStr(errorCode), errorCode);
- }
- #endif
- return errorCode;
- }
- void gl::errLogAll(int lineNumber, const char* fileName){
- Uint32 errorCode = gl::errLog(-2); //-2 for no print at all
- if(errorCode != GL_NO_ERROR){
- SDL_Log("%s : %4i:", fileName, lineNumber);
- gl::errLog(-1,errorCode);
- do {
- gl::errLog(-1);
- } while(errorCode != GL_NO_ERROR);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement