Hi everyone!
I am currently working with JOGL 1.1 and i'm running into a problem and I hope you could help :) I'm trying to draw 2 simple objects using the couple gl.glPushMatrix() & glPopMatrix() to draw them independently. But it doesn't seem to work: the first one is draw correctly but the second one is not visble. And when I remove the calls to Push/PopMatrix i can see my 2 triangles in my scene. Here's the drawing code : gl.glMatrixMode(GL.GL_MODELVIEW); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); gl.glLoadIdentity(); gl.glPushMatrix(); gl.glTranslatef(offsetX, offsetY, zoom); gl.glRotatef(xRot, 1.0f, 0.0f, 0.0f); gl.glRotatef(yRot, 0.0f, 1.0f, 0.0f); gl.glRotatef(zRot, 0.0f, 0.0f, 1.0f); gl.glBegin(GL.GL_TRIANGLES); gl.glColor3f(1, 1, 0); gl.glVertex3f(0, 0, 1); gl.glColor3f(0, 1, 1); gl.glVertex3f(5, 0, -1); gl.glColor3f(1, 0, 1); gl.glVertex3f(5, 5, 0); gl.glEnd(); gl.glPopMatrix(); gl.glPushMatrix(); gl.glTranslatef(2.0f, 1.5f, 0.0f); gl.glBegin(GL.GL_TRIANGLES); gl.glColor3f(1, 0, 0); gl.glVertex3f(0, 0, 1); gl.glColor3f(0, 1, 0); gl.glVertex3f(5, 0, -1); gl.glColor3f(0, 0, 1); gl.glVertex3f(5, 5, 0); gl.glEnd(); gl.glPopMatrix(); Any clues why this is not working? |
Administrator
|
It's probably working, just not doing what you expect it to
![]() I'd advise resetting the values in the translate/rotate statements to zero, then gradually changing them so you can get a feel for what's going on. |
Thanks a lot! Didn't think it was that simple... feel kind of stupid right now ![]() |
Administrator
|
No reason to feel stupid -- I've been doing this a long time, and still it seems like every 3D program I ever write comes up with a black screen the first time I run it
![]() - My camera is (behind/facing away from/inside of/too far from/too near) the scene - The lights are off - My vertices are clockwise instead of counter-clockwise - I'm looking at the back side of single-sided polys - My matrices/transforms are not set up right I think 3D programs are just inherently hard to debug, since the graphics hardware is a black box that you can't see inside of. |
Nice checklist ![]() Indeed, they are... |
Free forum by Nabble | Edit this page |