glTranslate

Hi,

I am drawing a series of triangles using a for loop. These triangles are drawn using various values within arrays.

I can output the correct amount of triangles all at the correct size according to the array values. However I am wanting to output them in a line effect, one after the other.

So within my display method, I have a for loop, then I have something like this…

gl.glTriangles;
//for statement goes here…

//draw triangles here
//finish triangles here

gl.glTranslate(translateVariable, 0.0f, 0.0f);
translateVariable++;

//end for loop

So, I thought that this would then draw one triangle, then translate along the x axis a bit, draw another triangle, move along the x axis again… and so on. Until the for loop ends.

The triangles are all draw, but on top of one another, how can I make them draw one, then move along the x axis a little, draw the next, then again move along the x axis, etc.

Any help would be great! I’m thinking that its a simple error that I’m making!

Thanks

I’m drawing sphere’s cones and cylinders along the coordinate axes to make it easier to see what’s going on, I do it like this

private void buildCords(GL gl,GLU glu)
{
theCords = gl.glGenLists (3);
gl.glNewList(theCords, GL.GL_COMPILE);
// X axis made of spheres
for (float x = -10.0f; x < 10.0f; x++)
{
gl.glPushMatrix();
gl.glTranslatef(x, 0.0f, 0.0f);
glu.gluSphere(glu.gluNewQuadric(), 0.5f, 24, 24);
gl.glPopMatrix();
}

    // Y axis made of cones
    for (float y = -10.0f; y < 10.0f; y++)
    {
      gl.glPushMatrix(); 

      gl.glTranslatef(0.0f, y, 0.0f); 
      gl.glRotatef( 90.0f, 1.0f, 0.0f, 0.0f );
      glu.gluCylinder(glu.gluNewQuadric(), 0.5f, 0.0f,  0.5f,  24, 24); 
      gl.glPopMatrix();
    } 

    // Z axis made of cylinders
    for (float z = -10.0f; z < 10.0f; z++)
    { 
     gl.glPushMatrix(); 

      gl.glTranslatef(0.0f, 0.0f, z); 
      glu.gluCylinder(glu.gluNewQuadric(), 0.5f, 0.5f,  0.5f,  24, 24); 
      gl.glPopMatrix();
    } 
    gl.glEndList();

}