Fix terminal warning flood, and improve error detection. Thanks to vlj for help

This commit is contained in:
Marianne Gagnon 2014-03-15 14:39:27 -04:00
parent 1b4863d7aa
commit 037688b020

View File

@ -63,69 +63,77 @@ PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
static bool is_gl_init = false;
//#define ARB_DEBUG_OUTPUT
#ifdef DEBUG
#define ARB_DEBUG_OUTPUT
#endif
#ifdef ARB_DEBUG_OUTPUT
static
void debugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
static void
#ifdef WIN32
CALLBACK
#endif
debugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
const GLchar* msg, const void *userparam)
{
switch(source)
{
case GL_DEBUG_SOURCE_API_ARB:
printf("[API]");
Log::warn("GLWrap", "OpenGL debug callback - API");
break;
case GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB:
printf("[WINDOW_SYSTEM]");
Log::warn("GLWrap", "OpenGL debug callback - WINDOW_SYSTEM");
break;
case GL_DEBUG_SOURCE_SHADER_COMPILER_ARB:
printf("[SHADER_COMPILER]");
Log::warn("GLWrap", "OpenGL debug callback - SHADER_COMPILER");
break;
case GL_DEBUG_SOURCE_THIRD_PARTY_ARB:
printf("[THIRD_PARTY]");
Log::warn("GLWrap", "OpenGL debug callback - THIRD_PARTY");
break;
case GL_DEBUG_SOURCE_APPLICATION_ARB:
printf("[APPLICATION]");
Log::warn("GLWrap", "OpenGL debug callback - APPLICATION");
break;
case GL_DEBUG_SOURCE_OTHER_ARB:
printf("[OTHER]");
Log::warn("GLWrap", "OpenGL debug callback - OTHER");
break;
}
switch(type)
{
case GL_DEBUG_TYPE_ERROR_ARB:
printf("[ERROR]");
Log::warn("GLWrap", " Error type : ERROR");
break;
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB:
printf("[DEPRECATED_BEHAVIOR]");
Log::warn("GLWrap", " Error type : DEPRECATED_BEHAVIOR");
break;
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB:
printf("[UNDEFINED_BEHAVIOR]");
Log::warn("GLWrap", " Error type : UNDEFINED_BEHAVIOR");
break;
case GL_DEBUG_TYPE_PORTABILITY_ARB:
printf("[PORTABILITY]");
Log::warn("GLWrap", " Error type : PORTABILITY");
break;
case GL_DEBUG_TYPE_PERFORMANCE_ARB:
printf("[PERFORMANCE]");
Log::warn("GLWrap", " Error type : PERFORMANCE");
break;
case GL_DEBUG_TYPE_OTHER_ARB:
printf("[OTHER]");
Log::warn("GLWrap", " Error type : OTHER");
break;
}
switch(severity)
{
case GL_DEBUG_SEVERITY_HIGH_ARB:
printf("[HIGH]");
Log::warn("GLWrap", " Severity : HIGH");
break;
case GL_DEBUG_SEVERITY_MEDIUM_ARB:
printf("[MEDIUM]");
Log::warn("GLWrap", " Severity : MEDIUM");
break;
case GL_DEBUG_SEVERITY_LOW_ARB:
printf("[LOW]");
Log::warn("GLWrap", " Severity : LOW");
break;
}
printf("%s\n", msg);
if (msg)
Log::warn("GLWrap", " Message : %s", msg);
}
#endif
@ -227,6 +235,12 @@ static GLuint LoadShader(const char * file, unsigned type)
delete[] ErrorMessage;
}
GLenum glErr = glGetError();
if (glErr != GL_NO_ERROR)
{
Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr);
}
return Id;
}
@ -254,6 +268,12 @@ GLuint LoadProgram(const char * vertex_file_path, const char * fragment_file_pat
glDeleteShader(VertexShaderID);
glDeleteShader(FragmentShaderID);
GLenum glErr = glGetError();
if (glErr != GL_NO_ERROR)
{
Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr);
}
return ProgramID;
}
@ -284,6 +304,12 @@ GLuint LoadProgram(const char * vertex_file_path, const char * geometry_file_pat
glDeleteShader(GeometryShaderID);
glDeleteShader(FragmentShaderID);
GLenum glErr = glGetError();
if (glErr != GL_NO_ERROR)
{
Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr);
}
return ProgramID;
}
@ -307,6 +333,13 @@ GLuint LoadTFBProgram(const char * vertex_file_path, const char **varyings, unsi
delete[] ErrorMessage;
}
glDeleteShader(Shader);
GLenum glErr = glGetError();
if (glErr != GL_NO_ERROR)
{
Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr);
}
return Program;
}
@ -329,7 +362,16 @@ void setTexture(unsigned TextureUnit, GLuint TextureId, GLenum MagFilter, GLenum
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, MinFilter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, allowAF ? UserConfigParams::m_anisotropic : 0);
int aniso = UserConfigParams::m_anisotropic;
if (aniso == 0) aniso = 1;
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, allowAF ? (float)aniso : 1.0f);
GLenum glErr = glGetError();
if (glErr != GL_NO_ERROR)
{
Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr);
}
}
static void drawTexColoredQuad(const video::ITexture *texture, const video::SColor *col, float width, float height,
@ -355,6 +397,12 @@ static void drawTexColoredQuad(const video::ITexture *texture, const video::SCol
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
GLenum glErr = glGetError();
if (glErr != GL_NO_ERROR)
{
Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr);
}
}
void drawTexQuad(const video::ITexture *texture, float width, float height,
@ -370,6 +418,12 @@ void drawTexQuad(const video::ITexture *texture, float width, float height,
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
GLenum glErr = glGetError();
if (glErr != GL_NO_ERROR)
{
Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr);
}
}
void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
@ -410,7 +464,8 @@ void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect
float tex_height = sourceRect.LowerRightCorner.Y - sourceRect.UpperLeftCorner.Y;
tex_height /= ss.Height * 2.;
if (texture->isRenderTarget()) {
if (texture->isRenderTarget())
{
tex_height = - tex_height;
}
@ -450,6 +505,12 @@ void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect
if (clipRect)
glDisable(GL_SCISSOR_TEST);
glUseProgram(0);
GLenum glErr = glGetError();
if (glErr != GL_NO_ERROR)
{
Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr);
}
}
void GL32_draw2DRectangle(video::SColor color, const core::rect<s32>& position,
@ -508,4 +569,10 @@ void GL32_draw2DRectangle(video::SColor color, const core::rect<s32>& position,
if (clip)
glDisable(GL_SCISSOR_TEST);
glUseProgram(0);
GLenum glErr = glGetError();
if (glErr != GL_NO_ERROR)
{
Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr);
}
}