glMaterial and Print3D

Ran into a problem and didn’t find anything on the web, so posting here for anyone who runs into it again.


Noticed that after calling glMaterialf my calls to Print3D.Flush() would cause an error



glDrawElements(GL_TRIANGLES, (VertexCount/2)*3, GL_UNSIGNED_SHORT, m_pFacesFont); failed



After a couple of hours the solution was the GL flag passed to glMaterialfv.

I was passing GL_FRONT. The problem went away after I passed it GL_FRONT_AND_BACK




Thanks for reporting this issue and the workaround. Obviously this shouldn’t be breaking Print3D so we’ll have a look at what’s going on and I’ll post here when I know more.

What is happening is this:

According to the OpenGL ES spec, the only legal value to pass to the glMaterialf function is GL_FRONT_AND_BACK. Anything else will cause glGetError() to return a value.

Print3D calls glGetError() after its call to glDrawElements() and if it is a value it gives out the message that you've seen. But if glError is already set by the call to glMaterialf then the message will appear anyway, even if Print3D is fine and so it does.

This would happen if any of the GL calls in your program fail. You're solution is correct, but the message from Print3D is misleading and I'll look at improving this.

Gordon2008-09-30 11:28:28