NEWT’s event model is pretty simple.
It spawns one Event Dispatch Thread (EDT) for each unique Display
which role is to handle:
- input events
- window lifecycle actions (window visibility, resize, .. etc)
- not rendering
High performance rendering is achieved without being blocked by input events
and the other way around, ie rendering does not disturb / lag user input.
This gives you fluent animation even for complex models.
Lately we had to create NewtCanvasAWT, hooking a NEWT window natively to an AWT Canvas.
This enables us to use both worlds, AWT/Swing UI and decoupled high performance rendering.
How to pass user input back to the rendering loop ?
Shows you how to use a fifo to pipe events from the EDT (listener) to the rendering loop.
How to inject some GL action to the rendering loop ?
Shows you how to inject GL render actions into a GL fifo from another thread.
AWT agnostic input event listener
We also have a way to write AWT agnostic input event listener:
We provide some utilities to make life a bit easier.
These are not really necessary, ie you could write and use your own, sure.
The NEWT threading requirements are easy – they are just none for rendering,
and the input event listener should better not lock the rendering GL context.
Well, they can using GLContext.setSynchronized(true) etc ..
,
but that would be a pity performance wise.