added DEBUG_GL_ERROR debug functionality
git-svn-id: svn://anubis/misc/wfobj@215 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
parent
3a42a0cb47
commit
b2ab1fc98b
26
WFObj.cc
26
WFObj.cc
@ -69,6 +69,23 @@ static string basePath(const string & str)
|
|||||||
return "";
|
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 ******/
|
/****** WFObj functions ******/
|
||||||
|
|
||||||
@ -180,6 +197,7 @@ void WFObj::processInputLine(const std::string & input)
|
|||||||
|
|
||||||
GLuint WFObj::render(bool doTextureInfo)
|
GLuint WFObj::render(bool doTextureInfo)
|
||||||
{
|
{
|
||||||
|
checkGLError();
|
||||||
GLuint list = glGenLists(1);
|
GLuint list = glGenLists(1);
|
||||||
glNewList(list, GL_COMPILE);
|
glNewList(list, GL_COMPILE);
|
||||||
int len = m_data.size();
|
int len = m_data.size();
|
||||||
@ -348,6 +366,7 @@ GLuint WFObj::render(bool doTextureInfo)
|
|||||||
inMaterial = false;
|
inMaterial = false;
|
||||||
}
|
}
|
||||||
glEndList();
|
glEndList();
|
||||||
|
checkGLError();
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,6 +502,7 @@ void WFObj::WFMtl::renderBegin(const string & mtlname, bool doTextureInfo)
|
|||||||
int num_stmts = stmts.size();
|
int num_stmts = stmts.size();
|
||||||
bool foundTexture = false;
|
bool foundTexture = false;
|
||||||
bool didSomething = false;
|
bool didSomething = false;
|
||||||
|
checkGLError();
|
||||||
for (int i = 0; i < num_stmts; i++)
|
for (int i = 0; i < num_stmts; i++)
|
||||||
{
|
{
|
||||||
string & type = stmts[i][0];
|
string & type = stmts[i][0];
|
||||||
@ -584,6 +604,7 @@ void WFObj::WFMtl::renderBegin(const string & mtlname, bool doTextureInfo)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkGLError();
|
||||||
if (didSomething)
|
if (didSomething)
|
||||||
{
|
{
|
||||||
pushAttributes();
|
pushAttributes();
|
||||||
@ -605,6 +626,7 @@ void WFObj::WFMtl::renderBegin(const string & mtlname, bool doTextureInfo)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
checkGLError();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WFObj::WFMtl::pushAttributes()
|
void WFObj::WFMtl::pushAttributes()
|
||||||
@ -616,7 +638,9 @@ void WFObj::WFMtl::pushAttributes()
|
|||||||
cout << " glPushAttrib(GL_LIGHTING_BIT | GL_TEXTURE_BIT | GL_ENABLE_BIT)"
|
cout << " glPushAttrib(GL_LIGHTING_BIT | GL_TEXTURE_BIT | GL_ENABLE_BIT)"
|
||||||
<< endl;
|
<< endl;
|
||||||
#endif
|
#endif
|
||||||
|
checkGLError();
|
||||||
glPushAttrib(GL_LIGHTING_BIT | GL_TEXTURE_BIT | GL_ENABLE_BIT);
|
glPushAttrib(GL_LIGHTING_BIT | GL_TEXTURE_BIT | GL_ENABLE_BIT);
|
||||||
|
checkGLError();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WFObj::WFMtl::renderEnd(const string & mtlname, bool doTextureInfo)
|
void WFObj::WFMtl::renderEnd(const string & mtlname, bool doTextureInfo)
|
||||||
@ -629,7 +653,9 @@ void WFObj::WFMtl::renderEnd(const string & mtlname, bool doTextureInfo)
|
|||||||
#ifdef DEBUGGL
|
#ifdef DEBUGGL
|
||||||
cout << " glPopAttrib()" << endl;
|
cout << " glPopAttrib()" << endl;
|
||||||
#endif
|
#endif
|
||||||
|
checkGLError();
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
|
checkGLError();
|
||||||
m_attributesPushed = false;
|
m_attributesPushed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user