Is it possible to disable automatic redisplay (on resizing etc)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Is it possible to disable automatic redisplay (on resizing etc)

GiGurra
I'd like to know if there is a way to disable the jogl EDT thread from doing redisplays when the window is resized etc.
I would like my own animator thread to be the only source for display invocations. Is this possible?

Sure I could put a guard in the display function that "if (currentThread != desiredThread) return",
but that is a little ugly ;).

Using NEWT GlWindow btw rc 11 on windows 7 64 bit with oracle's 64 bit jre7_u6

Printing the current thread inside the GlEventListener's display func I get

[ Sat Dec 08 16:48:37 CET 2012, INFO ] : Thread[main-Display-.windows_nil-1-EDT-1,5,main]
[ Sat Dec 08 16:48:37 CET 2012, INFO ] : Thread[main,5,main]
[ Sat Dec 08 16:48:37 CET 2012, INFO ] : Thread[main-Display-.windows_nil-1-EDT-1,5,main]
[ Sat Dec 08 16:48:37 CET 2012, INFO ] : Thread[main,5,main]
[ Sat Dec 08 16:48:37 CET 2012, INFO ] : Thread[main-Display-.windows_nil-1-EDT-1,5,main]
[ Sat Dec 08 16:48:37 CET 2012, INFO ] : Thread[main,5,main]
[ Sat Dec 08 16:48:37 CET 2012, INFO ] : Thread[main-Display-.windows_nil-1-EDT-1,5,main]
[ Sat Dec 08 16:48:37 CET 2012, INFO ] : Thread[main,5,main]

The reason is that the thread named "Thread[main,5,main]" performs world state changes when
it is not working in the display function, and if another thread gets into the display function while
"Thread[main,5,main]" is doing world state changes......bad things happen. Right now I've had to
lock the whole world state while any thread is in the display function, but I do not want to do that....
if that EDT thread wasn't there and messing things up I wouldn't need to :).

It's a matter of nice design rather than performance. The more things you "must remember",
the more chance to make mistakes.
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to disable automatic redisplay (on resizing etc)

Sven Gothel
Administrator
On 12/08/2012 04:55 PM, GiGurra [via jogamp] wrote:
> I'd like to know if there is a way to disable the jogl EDT thread from doing
> redisplays when the window is resized etc.
> I would like my own animator thread to be the only source for display
> invocatioons. Is this possible?

It is not just possible, but already build-in.

Implement your own GLAnimatorControl
and register it via GLAutoDrawable's setAnimator(..), see API doc.

If in doubt, check the source code.

It is crucial to implement the GLAnimatorControl's isAnimating() etc .. methods.

GLAutoDrawable will skip a display call when issued by the native windowing
system, like at resize, if an animator is attached and animating.

This way we guarantee fluent animation.

~Sven



signature.asc (909 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to disable automatic redisplay (on resizing etc)

GiGurra
Thank you, this seems to have solved my problems.
I made a dummy control implementation, with all hardcoded responses.

I tried resizing and saw that edt was polling isAnimating and getThread, which I have hard coded to true and null for now...and that seems to work ;).