added DEBUG_GL_ERROR debug functionality

git-svn-id: svn://anubis/misc/wfobj@215 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
josh 2009-11-18 00:20:14 +00:00
parent 3a42a0cb47
commit b2ab1fc98b

View File

@ -69,6 +69,23 @@ static string basePath(const string & str)
return "";
}
//#define DEBUG_GL_ERROR
#ifdef DEBUG_GL_ERROR
#define checkGLError() checkGLErrorLine(__FUNCTION__, __LINE__)
#else
#define checkGLError()
#endif
static void checkGLErrorLine(const char * function, int line)
{
GLenum err = glGetError();
if (err != 0)
{
cerr << "gl error in " << function
<< ": " << err << " (0x" << hex << err << ") at line "
<< dec << line << endl;
}
}
/****** WFObj functions ******/
@ -180,6 +197,7 @@ void WFObj::processInputLine(const std::string & input)
GLuint WFObj::render(bool doTextureInfo)
{
checkGLError();
GLuint list = glGenLists(1);
glNewList(list, GL_COMPILE);
int len = m_data.size();
@ -348,6 +366,7 @@ GLuint WFObj::render(bool doTextureInfo)
inMaterial = false;
}
glEndList();
checkGLError();
return list;
}
@ -483,6 +502,7 @@ void WFObj::WFMtl::renderBegin(const string & mtlname, bool doTextureInfo)
int num_stmts = stmts.size();
bool foundTexture = false;
bool didSomething = false;
checkGLError();
for (int i = 0; i < num_stmts; i++)
{
string & type = stmts[i][0];
@ -584,6 +604,7 @@ void WFObj::WFMtl::renderBegin(const string & mtlname, bool doTextureInfo)
}
}
checkGLError();
if (didSomething)
{
pushAttributes();
@ -605,6 +626,7 @@ void WFObj::WFMtl::renderBegin(const string & mtlname, bool doTextureInfo)
}
}
}
checkGLError();
}
void WFObj::WFMtl::pushAttributes()
@ -616,7 +638,9 @@ void WFObj::WFMtl::pushAttributes()
cout << " glPushAttrib(GL_LIGHTING_BIT | GL_TEXTURE_BIT | GL_ENABLE_BIT)"
<< endl;
#endif
checkGLError();
glPushAttrib(GL_LIGHTING_BIT | GL_TEXTURE_BIT | GL_ENABLE_BIT);
checkGLError();
}
void WFObj::WFMtl::renderEnd(const string & mtlname, bool doTextureInfo)
@ -629,7 +653,9 @@ void WFObj::WFMtl::renderEnd(const string & mtlname, bool doTextureInfo)
#ifdef DEBUGGL
cout << " glPopAttrib()" << endl;
#endif
checkGLError();
glPopAttrib();
checkGLError();
m_attributesPushed = false;
}
}