NewtCanvasAWT Examples

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

NewtCanvasAWT Examples

snmvaughan
Are there any examples which use the NewtCanvasAWT?  If I create a Window and use it in the constructor for NewtCanvasAWT, then a 2ndScreen is allocated during the reparenting process.  This occurs because isNativeWindowValid() returns false (the window isn't displayed yet), which throws off the reference counts used in Display.  Enabling the debug for Display demonstrates the reference count is at 2.

-----------

Display.create(Windows_nil) BEGIN DisplayMap[] entries: 0 - AWT-EventQueue-0
Display.create(Windows_nil) NEW: refCount 0, NEWT-Display[Windows_nil, refCount 0, hasEDT false, null] AWT-EventQueue-0
Display.create(Windows_nil) CreateNative: NEWT-Display[Windows_nil, refCount 1, hasEDT true, class javax.media.nativewindow.windows.WindowsGraphicsDevice[type Windows, handle 0x0]] AWT-EventQueue-0
Display.create(Windows_nil) END DisplayMap[] entries: 1 - AWT-EventQueue-0
  [0] Windows_nil -> NEWT-Display[Windows_nil, refCount 1, hasEDT true, class javax.media.nativewindow.windows.WindowsGraphicsDevice[type Windows, handle 0x0]]
Detected screen size 1920x1200
Display.create(Windows_nil) BEGIN DisplayMap[] entries: 1 - AWT-EventQueue-0
  [0] Windows_nil -> NEWT-Display[Windows_nil, refCount 1, hasEDT true, class javax.media.nativewindow.windows.WindowsGraphicsDevice[type Windows, handle 0x0]]
Display.create(Windows_nil) REUSE: refCount 1, NEWT-Display[Windows_nil, refCount 1, hasEDT true, class javax.media.nativewindow.windows.WindowsGraphicsDevice[type Windows, handle 0x0]] AWT-EventQueue-0
Display.create(Windows_nil) END DisplayMap[] entries: 1 - AWT-EventQueue-0
  [0] Windows_nil -> NEWT-Display[Windows_nil, refCount 2, hasEDT true, class javax.media.nativewindow.windows.WindowsGraphicsDevice[type Windows, handle 0x0]]
Detected screen size 1920x1200
Reply | Threaded
Open this post in threaded view
|

Re: NewtCanvasAWT Examples

Rami Santina
Administrator
Check the following if you havent already

http://github.com/sgothel/jogl/tree/master/src/junit/com/jogamp/test/junit/newt/parenting/

and post ur code here it could be useful to see exactly wat ur doing

when the isNativeWindowValid return false that means its not initialized so im guessing ur new parent is not visible

you dont need it to be visible on create but you should at some point make it visible.

like this senario works:

overlayedNewtComponent = new NewtCanvasAWT(glWindow);
overlayedAWTParentContainer.add(overlayedNewtComponent, BorderLayout.CENTER);
overlayedAWTParentContainer.setVisible(true);

Then when the frame is visible the gl window get created :)



Reply | Threaded
Open this post in threaded view
|

Re: NewtCanvasAWT Examples

snmvaughan
I took a look at the junit tests and found that one of them locked up consistently.  When I run all of the unit tests within TestParenting01aAWT, the test fails on testWindowParenting04ReparentNewtWin2TopLayouted.  If I run just that one test independently, it seems to work fine.

NEWT looks pretty interesting, but it needs some work to make it more stable and predictable.  Although the test cases complete without reporting errors, each leaves running non-daemon threads.  This isn't a problem for an individual test, but if NEWT were part of a larger application It could definitely cause some issues.

Looking internally within the running instance, the Display reference counter is incorrect.  The reference counter is used to determine when the Display's EDT is longer necessary.  There is no finalize() method defined for screen, so it is have to have a Screen instance garbage collected without decrementing the reference count.  NewtCanvasAWT consistently reparents the GLWindow instances, creating second screens, which explains why the reference count within the Display is incorrect.

I see tests using multiple windows, but I didn't see any tests that independently manage those windows.  The tests construct the windows run a few operations, and then destroy the pair.  Since I'm looking to operate within a JDesktopPane, being able to create and destroy a window without negatively impacting other windows is a requirement.