I was playing around with a simple JOGL example working with GLEventListener and the Animator class. I build a standard Processing sketch which opens a second OPENGL frame with its own framerate
Quote:
import javax.media.opengl.*;
import com.sun.opengl.util.FPSAnimator;
void setup() {
size(400, 300);
Frame f = new Frame("OPENGL frame");
GLCanvas canvas = new GLCanvas();
canvas.addGLEventListener(new GLRenderer());
f.add(canvas);
f.setSize(300, 300);
f.setLocation(0,0);
f.setUndecorated(true);
f.show();
FPSAnimator animator = new FPSAnimator(canvas, 60);
animator.start();
}
void draw() {
background(0);
fill(255);
rect(10,10,frameCount%100,10);
}
class GLRenderer implements GLEventListener {
GL gl;
public void init(GLAutoDrawable drawable) {
this.gl = drawable.getGL();
gl.glClearColor(0, 0, 0, 0);
}
public void display(GLAutoDrawable drawable) {
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );
gl.glColor3f(1, 1, 1);
gl.glRectf(-0.8, 0.8, frameCount%100/100f -0.8, 0.7);
}
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
}
public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
}
}