Posted by
AlexRNL on
Apr 28, 2011; 10:06am
URL: https://forum.jogamp.org/PushMatrix-PopMatrix-tp2874026.html
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?