Cheney
asked on
JOGL's GLCanvas swapBuffer() is really slow... need speed up
I'm trying to put together a simple game in Java with jogl. I'm using GLCanvas on a JFrame.
My main class implements GLEventListener and does all the game logic and rendering in the overriden GLEventListener's display() method, the listener is registered with the GLCanvas. There is an infinate loop that repeatly calls display() on the GLCanvas instance.
All the rendering works fine, the problem is that no matter how may quads I'm drawing (even doing nothing in the display() method) I can never pass about 70fps.
If I call mCanvas.setAutoSwapBufferM ode(false) , I get massive frame rates (~1000fps) but no automatic render. So I call swapBuffers myself - rendering works again but the frame rate drops to ~70fps again.
Seems to me that swapping the buffers should be relativily fast, compared to the actual compositing of the back buffer anyway. In other games I've made (C++/OpenGL/Direct3D) swapping the buffers has taken less than 1ms. Here I'm seeing about 15ms.
I guess I've set up JOGL or the GLCanvas wrong but can't figure it out.
Anyone come across this already?
My main class implements GLEventListener and does all the game logic and rendering in the overriden GLEventListener's display() method, the listener is registered with the GLCanvas. There is an infinate loop that repeatly calls display() on the GLCanvas instance.
All the rendering works fine, the problem is that no matter how may quads I'm drawing (even doing nothing in the display() method) I can never pass about 70fps.
If I call mCanvas.setAutoSwapBufferM
Seems to me that swapping the buffers should be relativily fast, compared to the actual compositing of the back buffer anyway. In other games I've made (C++/OpenGL/Direct3D) swapping the buffers has taken less than 1ms. Here I'm seeing about 15ms.
I guess I've set up JOGL or the GLCanvas wrong but can't figure it out.
Anyone come across this already?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Missed that. Seems obvious now I think about it.
The whole game loop now takes on average just under 2ms. Smashing!