I’m having trouble with Rendering using JOGL.
I am trying to create a program that reads a string of characters, drawing something different for each character. For example, if the program reads ‘F’ then I want to draw a line. Am I supposed to do ALL drawing inside the display() function? And if so, I tried using a while loop that exited after all the characters were read inside the display function and for some reason my drawing only appears half the time that I execute the program. (e.g. every time I press run, only once in awhile I will see the line.) I assume it has something to do with the display() function getting called in a loop…take a look at my code:
public void display(GLAutoDrawable glDrawable) {
final GL gl = glDrawable.getGL();
GLU glu = new GLU();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
gl.glTranslatef(0, 0, -6.0f);
gl.glColor3f(1.0f, 0.0f, 0.0f);
while(i < l.sLength()){
gl.glBegin(GL.GL_LINES);
switch(l.readNext()){
case 'F':
up += 0.5f;
gl.glVertex3f(curX, curY, 0.0f);
gl.glVertex3f(0.0f, up, 0.0f);
break;
case '+':
System.out.println("+");
break;
case '-':
System.out.println("-");
break;
}
i++;
curY += up;
}
gl.glEnd();
I apologize if that formatted incorrectly!