title: Having trouble creating an articulated arm in OpenGL
body: <p>I am attempting to create an articulated arm in OpenGL (JAVA). I have started by creating a drawTriangle method, which draws 3 triangles onto the canvas, all slightly overlapping each other. I am now attempting to code a drawArm method, which starts by calling the drawTriangle method, and then using glPushMatrix, glPopMatrix, glTranslate, and glRotate, will be able to rotate the arm at specific points (where the triangles overlap).</p>
  
  <p>Here is my drawTriangle method:</p>
  
  <pre><code>public void drawTriangle(GL gl, int x1, int y1, int x2, int y2, 
          int x3, int y3) {
  
      gl.glTranslatef(-2.0f, -1.5f, -6.0f);
  
      // Drawing first red triangle
      gl.glBegin(GL.GL_TRIANGLES);
      gl.glColor3f(1f, 0f, 0f);
      gl.glVertex3f(1f, 1f, 0.0f);    // Bottom Left
      gl.glVertex3f(1f, 1.2f, 0.0f);     // Top left
      gl.glVertex3f(2f, 1.1f, 0.0f);      // Pointy bit
      gl.glEnd();   
      gl.glTranslatef(0.9f, 0f, 0f);
  
      // Drawing first red triangle
      gl.glBegin(GL.GL_TRIANGLES);
      gl.glColor3f(0f, 1f, 0f);
      gl.glVertex3f(1f, 1f, 0.0f);    // Bottom Left
      gl.glVertex3f(1f, 1.2f, 0.0f);     // Top left
      gl.glVertex3f(2f, 1.1f, 0.0f);      // Pointy bit
      gl.glEnd();   
      gl.glTranslatef(0.9f, 0f, 0f);
  
      // Drawing first red triangle
      gl.glBegin(GL.GL_TRIANGLES);
      gl.glColor3f(0f, 0f, 1f);
      gl.glVertex3f(1f, 1f, 0.0f);    // Bottom Left
      gl.glVertex3f(1f, 1.2f, 0.0f);     // Top left
      gl.glVertex3f(2f, 1.1f, 0.0f);      // Pointy bit
      gl.glEnd();   
      gl.glTranslatef(0.9f, 0f, 0f);
  }
  </code></pre>
  
  <p>And here is my starting attempt at my drawArm method:</p>
  
  <pre><code>public void drawArm(GL gl, float offset, float angle1, float angle2) {
  
      // Call drawTriangle method
      drawTriangle(gl,0,0,0,5,10,7);
      gl.glPushMatrix();
      gl.glTranslatef(-2.0f,-1.5f,-6.0f);  // Translates to origin of first triangle
      gl.glRotatef(offset, angle1, angle2, offset);
      gl.glPopMatrix();
      gl.glEnd();   
  }
  </code></pre>
  
  <p>I will then call the drawArm method from inside my display() method, where offset is the length of each arm, angle 1 changes the rotation between triangle 1 and 2, and angle 2 changes the rotation between triangle 2 and 3.</p>
  
  <p>Any help with writing the drawArm method?</p>