JOGL with my game loop

I’m wondering how I should do rendering with my game loop when using jogl. Right now I have a loop that goes through and does all the usual stuff:

handle input
update logic
render

This works fine for java2D obviously, but I’m not sure how to do this with jogl. I could just use tha Animator but then rendering is on a seperate thread from logic updates etc. and I dont want that. From what I know, the Animator just repeatedly calls display(GLDrawable drawable), however I don’t know if it is safe for me to call display(myGLCanvas). Will my old game loop work if I just replace the call to my render() method with a call to display(myGLCanvas)?

I read in another post that everything is done in display(), does this mean I should just use display for my gameloop and do logic updates, input handling, and whatever else from here and just let the animator update it?

My other concern with doing it this way is whether the Animator (I’m actualy using FPSAnimator) is going to have millisecond accurate timing like I could get from using GAGE Timer, and other features like catching up on frames if it gets behind and vsyncing.

You can let your game loop out of the display method with the FPSAnimator as long as you don’t make any openGl call into it. If you do it (like unprojection…) this will fail since your are not in the good thread.

It’s how i’ve understood the jogl logic and i manage to have a good looking logio, but my application is not a game so…

so your saying to use display() as my game loop? what about calling display() in my own loop and passing it my GLCanvas, is that ok. If not, what is the problem?

You can only call the display method in a proper thread (i.e call setRenderingThread before your call to display) which is not very user friendly for me… but will work if done correctly.

(May be corrected by some Jogl experts)

You should never invoke the GLEventListener.display(GLDrawable) method directly. JOGL invokes this method for you when you call GLDrawable.display(). This is the method you should call to perform on-demand rendering. You should be able to call GLDrawable.display() from any thread.

Ah ok, so thats how its done! will do, thanks for the help.