I realize that using GLEventListener’s display() only swaps drawing buffer to display once. Is it possible to refresh the buffer manually?
public void display(GLDrawable drawable) {
GL gl = drawable.getGL();
gl.glColor3f(1, 1, 1);
line(gl, x0, y0, xn, yn);
gl.glFlush();
r = (float) ((Math.random() * 9)) / 8;
g = (float) ((Math.random() * 9)) / 8;
b = (float) ((Math.random() * 9)) / 8;
// This is used to slow down the animation speed... currently JOGL's
// animator will try to draw as fast as possible, using 100% CPU...
// this will give the CPU some breathing space.
try {
Thread.sleep(1000);
} catch (Exception ignore) {}
gl.glColor3f(r, g, b);
antialiasedLine(gl, x0, y0, xn, yn);
}
Thanks,
Jim Chen