Hi.
I’ve written a simple test program to measure the
performance of JOGL, but cannot get it to work as I wanted.
When I render a simple moving square (code below), it “breaks”, like it doesn’t wait for vsync.
The following picture shows how it looks:
http://www.ikanos.se/t/bar.png
Even if I set the drivers to enable vsync, the same thing occurs.
And I only get between 75-80 fps, so I really hope it’s limited by vertical refresh or it is very slow.
My system is:
Vendor: NVIDIA Corporation
Renderer: GeForce 256/AGP/SSE/3DNOW!
Version: 1.5.0
Does anyone have any ideas or suggestions???
public class FPSTest implements GLEventListener {
public static void main(String[] args) throws Exception {
new FPSTest().run();
}
void run() throws Exception {
GLCanvas glCanvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());
glCanvas.addGLEventListener(this);
Animator animator = new Animator(glCanvas);
Frame frame = new Frame("FPS test");
frame.add(glCanvas);
frame.setSize(500, 500);
frame.setVisible(true);
animator.start();
Thread.sleep(4000);
animator.stop();
System.out.println("Rendered " + count + " frames on 4 seconds = " + (count/4.0) + " fps.");
System.exit(0);
}
public void init(GLDrawable glDrawable) {}
int count = 0;
double angle = 0;
public void display(GLDrawable glDrawable) {
GL gl = glDrawable.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glTranslatef((float)Math.sin(angle)/2, 0, 0);
gl.glBegin(GL.GL_QUADS);
gl.glVertex2f(-0.2f,-0.7f);
gl.glVertex2f(-0.2f,0.7f);
gl.glVertex2f(0.2f,0.7f);
gl.glVertex2f(0.2f,-0.7f);
gl.glEnd();
count++;
angle += 0.1;
}
public void reshape(GLDrawable glDrawable, int i, int i1, int i2, int i3) {}
public void displayChanged(GLDrawable glDrawable, boolean b, boolean b1) {}
}