45int checkGlError(
const std::string& aInfo,
const char* aFile,
int aLine,
bool aThrow )
47 int result = glGetError();
57 errorMsg = wxString::Format(
"Error: %s: invalid enum", aInfo );
60 case GL_INVALID_VALUE:
61 errorMsg = wxString::Format(
"Error: %s: invalid value", aInfo );
64 case GL_INVALID_OPERATION:
65 errorMsg = wxString::Format(
"Error: %s: invalid operation", aInfo );
68 case GL_INVALID_FRAMEBUFFER_OPERATION:
70 GLenum status = glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT );
72 if( status != GL_FRAMEBUFFER_COMPLETE_EXT )
76 case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
77 errorMsg =
"The framebuffer attachment points are incomplete.";
80 case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
81 errorMsg =
"No images attached to the framebuffer.";
84 case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
85 errorMsg =
"The framebuffer does not have at least one image attached to it.";
88 case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
89 errorMsg =
"The framebuffer read buffer is incomplete.";
92 case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
93 errorMsg =
"The combination of internal formats of the attached images violates "
94 "an implementation dependent set of restrictions.";
97 case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT:
98 errorMsg =
"GL_RENDERBUFFER_SAMPLES is not the same for all attached render "
102 case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT:
103 errorMsg =
"Framebuffer incomplete layer targets errors.";
106 case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
107 errorMsg =
"Framebuffer attachments have different dimensions";
111 errorMsg.Printf(
"Unknown incomplete framebuffer error id %X", status );
116 errorMsg = wxString::Format(
"Error: %s: invalid framebuffer operation", aInfo );
121 case GL_OUT_OF_MEMORY:
122 errorMsg = wxString::Format(
"Error: %s: out of memory", aInfo );
125 case GL_STACK_UNDERFLOW:
126 errorMsg = wxString::Format(
"Error: %s: stack underflow", aInfo );
129 case GL_STACK_OVERFLOW:
130 errorMsg = wxString::Format(
"Error: %s: stack overflow", aInfo );
134 errorMsg = wxString::Format(
"Error: %s: unknown error", aInfo );
138 if( result != GL_NO_ERROR )
143 "in file '%s' on line %d." ),
148 throw std::runtime_error( (
const char*) errorMsg.char_str() );
152 wxString msg = wxString::Format( wxT(
"glGetError() '%s' in file '%s' on line %d." ),
167static void GLAPIENTRY
debugMsgCallback( GLenum aSource, GLenum aType, GLuint aId, GLenum aSeverity,
168 GLsizei aLength,
const GLchar* aMessage,
169 const void* aUserParam )
173 case GL_DEBUG_SEVERITY_HIGH:
176 case GL_DEBUG_SEVERITY_MEDIUM:
179 case GL_DEBUG_SEVERITY_LOW:
182 case GL_DEBUG_SEVERITY_NOTIFICATION:
192 glEnable( GL_DEBUG_OUTPUT );
197 glDisable( GL_DEBUG_OUTPUT );
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
static const wxChar *const traceGalOpenGlError
Flag to enable debug output of the GAL OpenGL error checking.
void enableGlDebug(bool aEnable)
Enable or disable OpenGL driver messages output.
static void GLAPIENTRY debugMsgCallback(GLenum aSource, GLenum aType, GLuint aId, GLenum aSeverity, GLsizei aLength, const GLchar *aMessage, const void *aUserParam)
int checkGlError(const std::string &aInfo, const char *aFile, int aLine, bool aThrow)
Check if a recent OpenGL operation has failed.