Hi,
I am trying to use an array of variables to draw a series of 2d/3d shapes on a canvas…
When I use a for statement to loop through the array, its loops through the array endlessly. Is there any way to stop this, so that it will only loop through the array once??
here is a code snippet.
public void display(GLDrawable gLDrawable) {
for (int k=0; k<array.length; k++) {
final GL gl = gLDrawable.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
gl.glTranslate(-1.5f, 0.0f, -6.0f);
gl.glBegin(GL.GL_TRIANGLES);
//code to draw a 2d triangle…
gl.glEnd();
gl.glTranslate(3.0f, 0.0f, 0.0f);
}
}
I have a test array of length = 2. So in theory this should draw two trianlges (one over the top of each other), but i get a constant loop where there is a bigger triangle on the left of the canvas and a smaller triangle to the right…
could anyone shed some light onto why this is looping through my array endlessly??
Many Thanks,
lillyhammer