TomorrowPlusX
2006.08.03, 02:27 PM
Long ago I found a macro ( I think posted by arrekusu ) called glError, which will look for gl error state and display it to stdout.
#define glError() { \
GLenum err = glGetError(); \
while (err != GL_NO_ERROR) { \
printf("glError: %s caught at %s:%u\n", (char *)gluErrorString(err), __FILE__, __LINE__); \
err = glGetError(); \
} \
}
Ever since, I've used it very liberally in my code to help me keep gl happy. That and running my apps under gl profiler with "Break on GL Error" checked.
Now, I've come across a gl error which I simply don't understand. I can't figure out what's causing it, or why. Basically, I'm getting the error immediately after calling glEnd(), after drawing a bunch of quads. The error doesn't occur *before* calling glEnd, but occurs right after.
Here's a condensation of my offending code:
float texScale = water()->normalmapScale();
PatchVec::const_iterator it( _patches.begin() ), end( _patches.end() );
glError(); // no error here
glBegin( GL_QUADS );
for ( ; it != end; ++it )
{
const patch &p = *it;
glMultiTexCoord2f( GL_TEXTURE0, 0.0f, 0.0f);
glNormal3f( 0.0f, 0.0f, 1.0f );
glVertex3f( p.vertices[0].x, p.vertices[0].y, 0.0f );
glMultiTexCoord2f( GL_TEXTURE0, texScale, 0.0f);
glNormal3f( 0.0f, 0.0f, 1.0f );
glVertex3f( p.vertices[1].x, p.vertices[1].y, 0.0f );
glMultiTexCoord2f( GL_TEXTURE0, texScale, texScale );
glNormal3f( 0.0f, 0.0f, 1.0f );
glVertex3f( p.vertices[2].x, p.vertices[2].y, 0.0f );
glMultiTexCoord2f( GL_TEXTURE0, 0.0f, texScale );
glNormal3f( 0.0f, 0.0f, 1.0f );
glVertex3f( p.vertices[3].x, p.vertices[3].y, 0.0f );
glError(); // no error here
}
glError(); // no error here
glEnd();
glError(); // error shows up here
The error reported is "invalid operation".
I've trimmed and stripped the code clean and I still get the error. I can't figure out what the error is, or what's causing it.
Help! Please!
:blink:
#define glError() { \
GLenum err = glGetError(); \
while (err != GL_NO_ERROR) { \
printf("glError: %s caught at %s:%u\n", (char *)gluErrorString(err), __FILE__, __LINE__); \
err = glGetError(); \
} \
}
Ever since, I've used it very liberally in my code to help me keep gl happy. That and running my apps under gl profiler with "Break on GL Error" checked.
Now, I've come across a gl error which I simply don't understand. I can't figure out what's causing it, or why. Basically, I'm getting the error immediately after calling glEnd(), after drawing a bunch of quads. The error doesn't occur *before* calling glEnd, but occurs right after.
Here's a condensation of my offending code:
float texScale = water()->normalmapScale();
PatchVec::const_iterator it( _patches.begin() ), end( _patches.end() );
glError(); // no error here
glBegin( GL_QUADS );
for ( ; it != end; ++it )
{
const patch &p = *it;
glMultiTexCoord2f( GL_TEXTURE0, 0.0f, 0.0f);
glNormal3f( 0.0f, 0.0f, 1.0f );
glVertex3f( p.vertices[0].x, p.vertices[0].y, 0.0f );
glMultiTexCoord2f( GL_TEXTURE0, texScale, 0.0f);
glNormal3f( 0.0f, 0.0f, 1.0f );
glVertex3f( p.vertices[1].x, p.vertices[1].y, 0.0f );
glMultiTexCoord2f( GL_TEXTURE0, texScale, texScale );
glNormal3f( 0.0f, 0.0f, 1.0f );
glVertex3f( p.vertices[2].x, p.vertices[2].y, 0.0f );
glMultiTexCoord2f( GL_TEXTURE0, 0.0f, texScale );
glNormal3f( 0.0f, 0.0f, 1.0f );
glVertex3f( p.vertices[3].x, p.vertices[3].y, 0.0f );
glError(); // no error here
}
glError(); // no error here
glEnd();
glError(); // error shows up here
The error reported is "invalid operation".
I've trimmed and stripped the code clean and I still get the error. I can't figure out what the error is, or what's causing it.
Help! Please!
:blink: