I’ve been working on a level abstraction for jogl and I finally finished enough of to test and as usual it has some interesting bugs in it. The only one that has me stuck currently is that in my engine, when I enable the depth test, the polygons become fragmented (see pictures). I made a test case that did basically the exact same thing as my engine, but hardcoded in immediate mode and it worked fine, even with depth test enabled.
Fragmented Image:
http://www.imagehosting.com/out.php/i1193674_badimage.jpg
Desired Image:
http://www.imagehosting.com/out.php/i1193680_goodimage.jpg
I used a traceGL on both and per frame, I couldn’t tell where the commands went wrong.
Fragmented Polygon Trace output:
glClearColor(0.0,0.0,0.0,1.0)
glEnable(GL_DEPTH_TEST)
glEnable(GL_CULL_FACE)
glCullFace(GL_FRONT)
glViewport(0,0,500,478)
glViewport(0,0,500,478)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
glMultMatrixd(java.nio.DirectDoubleBufferU[pos=0 lim=16 cap=16])
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
glEnable(GL_LIGHTING)
glEnable(GL_LIGHT0)
glLightfv(GL_LIGHT0,GL_DIFFUSE,[0.4,0.4,0.6,1.0],0)
glLightfv(GL_LIGHT0,GL_SPECULAR,[1.0,1.0,1.0,1.0],0)
glLightfv(GL_LIGHT0,GL_POSITION,[5.0,5.0,5.0,1.0],0)
glLightfv(GL_LIGHT0,GL_SPOT_DIRECTION,[0.0,0.0,1.0,0.0],0)
glLightf(GL_LIGHT0,GL_SPOT_CUTOFF,180.0)
glLightf(GL_LIGHT0,GL_CONSTANT_ATTENUATION,1.0)
glLightf(GL_LIGHT0,GL_LINEAR_ATTENUATION,0.0)
glLightf(GL_LIGHT0,GL_QUADRATIC_ATTENUATION,0.0)
glPushMatrix()
glTranslatef(0.0,0.0,0.0)
glRotatef(0.0,0.0,0.0,0.0)
glIsEnabled(GL_BLEND) = false
glLoadIdentity()
glTranslatef(0.0,0.0,0.0)
glRotatef(0.0,0.0,0.0,0.0)
glIsEnabled(GL_LIGHTING) = true
glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,90.0)
glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE,[1.0,1.0,1.0,1.0],0)
glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,[1.0,1.0,1.0,1.0],0)
<!-- internals of glutSolidTeapot(1)
glPushAttrib(73736)
glEnable(3456)
glEnable(2977)
glEnable(3511)
glEnable(3508)
glPushMatrix()
glRotatef(270.0,1.0,0.0,0.0)
glScalef(0.5,0.5,0.5)
glTranslatef(0.0,0.0,-1.5)
glMap2f(3508,0.0,1.0,2,2,0.0,1.0,4,2,[0.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0],0)
glMap2f(3511,0.0,1.0,3,4,0.0,1.0,12,4,[1.4,0.0,2.4,1.4,-0.784,2.4,0.784,-1.4,2.4,0.0,-1.4,2.4,1.3375,0.0,2.53125,1.3375...48],0)
glMapGrid2f(14,0.0,1.0,14,0.0,1.0)
...
glMap2f(3511,0.0,1.0,3,4,0.0,1.0,12,4,[3.3,-0.0,2.4,3.3,0.25,2.4,2.7,0.25,2.4,2.7,-0.0,2.4,3.525,-0.0,2.49375,3.525...48],0)
glEvalMesh2(6914,0,14,0,14)
glPopMatrix()
glPopAttrib() -->
glIsEnabled(GL_LIGHTING) = true
glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE,[1.0,1.0,1.0,1.0],0)
glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,[1.0,1.0,1.0,1.0],0)
glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,90.0)
glPopMatrix()
glDisable(GL_LIGHTING)
glDisable(GL_LIGHT0)
And here’s the proper trace:
glCullFace(GL_FRONT) 1028
glEnable(GL_CULL_FACE) 2884
glEnable(GL_DEPTH_TEST) 2929
glEnable(GL_LIGHTING) 2896
glEnable(GL_LIGHT0)
glLightfv(GL_LIGHT0,GL_DIFFUSE,[0.4,0.4,0.6,1.0],0)
glLightfv(GL_LIGHT0,GL_SPECULAR,[1.0,1.0,1.0,1.0],0)
glLightfv(GL_LIGHT0,GL_POSITION,[5.0,5.0,5.0,1.0],0)
glLightfv(GL_LIGHT0,GL_SPOT_DIRECTION,[0.0,0.0,1.0,0.0],0)
glLightf(GL_LIGHT0,GL_SPOT_CUTOFF,180.0)
glLightf(GL_LIGHT0,GL_CONSTANT_ATTENUATION,1.0)
glLightf(GL_LIGHT0,GL_LINEAR_ATTENUATION,0.0)
glLightf(GL_LIGHT0,GL_QUADRATIC_ATTENUATION,0.0)
glViewport(0,0,500,478)
glViewport(0,0,500,478)
glMatrixMode(GL_PROJECTION) 5889
glMultMatrixd(java.nio.DirectDoubleBufferU[pos=0 lim=16 cap=16])
glMatrixMode(GL_MODELVIEW) 5888
glClearColor(0.0,0.0,0.0,1.0)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) 1604
glLoadIdentity()
glTranslatef(0.0,0.0,0.0)
<!--internals of glutSolidTeapot(1)
glPushAttrib(73736)
glEnable(3456)
glEnable(2977)
glEnable(3511)
glEnable(3508)
glPushMatrix()
glRotatef(270.0,1.0,0.0,0.0)
glScalef(0.5,0.5,0.5)
glTranslatef(0.0,0.0,-1.5)
glMap2f(3508,0.0,1.0,2,2,0.0,1.0,4,2,[0.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0],0)
glMap2f(3511,0.0,1.0,3,4,0.0,1.0,12,4,[1.4,0.0,2.4,1.4,-0.784,2.4,0.784,-1.4,2.4,0.0,-1.4,2.4,1.3375,0.0,2.53125,1.3375...48],0)
glMapGrid2f(14,0.0,1.0,14,0.0,1.0)
glEvalMesh2(6914,0,14,0,14)
...
glMap2f(3511,0.0,1.0,3,4,0.0,1.0,12,4,[3.3,-0.0,2.4,3.3,0.25,2.4,2.7,0.25,2.4,2.7,-0.0,2.4,3.525,-0.0,2.49375,3.525...48],0)
glEvalMesh2(6914,0,14,0,14)
glPopMatrix()
glPopAttrib() -->
I’d appreciate any advice or hearing if anyone has ever had this problem before. Also, I ran the same code on multiple machines when the problem first arose (but before I pinpointed it to the depth test) and the same thing happened, so I doubt it’s a driver issue, especially because one was nvidia and another ati.
Thankyou and sorry for the long post