I'm using the latest 2.1.5, on Windows 7
I've seen examples showing how to create Newt windows and reparent them to different Frames or canvas'es. But each time the native window handle was actually destroyed then recreated when reparented to a different parent window. Is there a way to use Newt API to create a child window under an AWT frame or canvas and reparent that child window without destroying/recreating the corresponding native window handle? The Newt page seems to infer so at http://jogamp.org/jogl/doc/NEWT-Overview.html "Since we use native reparenting, the native window resource keeps alive and hence your OpenGL application (GLEventListener) is not being asked to dispose all resources." But snippets derived from https://github.com/sgothel/jogl/blob/master/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01dAWT.java or http://jogamp.org/git/?p=jogl.git;a=blob;f=src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java;hb=HEAD showed the native handle was actually destroyed/recreated (e.g. using Spy++). I thought this was related to https://jogamp.org/bugzilla/show_bug.cgi?id=922 "Unable to preserve resources during NewtCanvasAWT reparenting" but this is fixed. When I do a reparenting, I always get ACTION_NATIVE_CREATION instead of ACTION_NATIVE_REPARENTING... http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/newt/Window.ReparentOperation.html Any tip welcome :-) Chrix |
Administrator
|
Hi
Don't make a confusion between the native window handle and the OpenGL resources. Do you reproduce the last problem with an existing test case?
Julien Gouesse | Personal blog | Website
|
> Don't make a confusion between the native window handle and the OpenGL resources. Ack... So no hope to preserve that native window handle when it is reparented, right? Newt is just intended to preserve the OpenGL resources? Just wanted to be sure I don't miss some way to leverage the Newt API's before having to write native code with Win32/CreateWindow/SetParent stuff..
On Wed, Mar 12, 2014 at 4:55 PM, gouessej [via jogamp] <[hidden email]> wrote: Hi |
Administrator
|
On 03/12/2014 11:37 PM, chrix [via jogamp] wrote:
>> Don't make a confusion between the native window handle and the >> OpenGL > resources. Ack... So no hope to preserve that native window handle > when it is reparented, right? NEWT's reparenting algorithm only issues a 'destroy' if: - Becomes CHILD-Window - new parent window is not realized yet, i.e. parent's window handle is null - forceRecreate - moving to a new incompatible screen/device - Becomes TOP-Level-Window - forceRecreate - reparenting failed In case 'destroy' is issued, recreation will follow as soon as the new parent window handle becomes available or the instant if becoming a top-level window. +++ In case 'destroy' must be issued, the hint 'REPARENT_HINT_BECOMES_VISIBLE' will preserve the GLState at destroy. The preserved GLState will be recovered when recreated. This mechanism exists to sooth the 'destroy' case. See: GLStateKeeper, GLEventListenerState Regularly used in cases: - OSX CALayer/Top-Level NEWT Reparenting - Android GLState preservation: 'Home Button', 'Rotation' .. +++ To avoid 'destroy' _and_ the GLState preservation, the NEWT window shall simply be reparented before parent's destruction. This is true for 'window hopping' as well as child->top transition. See TestParenting04AWT for example .. I hope this helps a bit .. +++ I will add the above to the NEWT documentation. > > > On Wed, Mar 12, 2014 at 4:55 PM, gouessej [via jogamp] <[hidden > email]> wrote: > > Hi > > Don't make a confusion between the native window handle and the > OpenGL resources. Yes, the GLState preservation mechanism is orthogonal but helping to sooth destroy in some cases .. see above. ~Sven signature.asc (894 bytes) Download Attachment |
Hi Sven: Thanks for the quick replies. My snippet is derived from TestParenting04AWT.java. I've added 4 lines marked with "// <<<<" to compare the window handle before and after reparenting.
Here's the output below. Do you think there's a way to write a snippet where a child window is moved to a different parent while preserving its own native handle on Windows? Handle before reparenting: 21237418 Handle after reparenting: 21302954 protected void winHopFrame2Frame(final boolean detachFirst) throws InterruptedException, InvocationTargetException { ... for(state=0; state<3; state++) { Thread.sleep(durationPerTest); switch(state) { case 0: SwingUtilities.invokeAndWait(new Runnable() {
public void run() { // 1 -> 2 if(detachFirst) { canvas1.setNEWTChild(null); canvas2.setNEWTChild(null);
} else { canvas2.setNEWTChild(null); // free g2 of w2 } long handle1 = glWindow2.getWindowHandle(); // <<<<<
canvas1.setNEWTChild(glWindow2); // put g2 -> w1. free g1 of w1 canvas2.setNEWTChild(glWindow1); // put g1 -> w2 frame1.invalidate();
frame2.invalidate(); frame1.validate(); frame2.validate(); long handle2 = glWindow2.getWindowHandle(); // <<<<<
System.out.println("Handle before reparenting: "+handle1); // <<<<< System.out.println("Handle after reparenting: "+handle2); // <<<<<
On Thu, Mar 13, 2014 at 12:16 AM, Sven Gothel [via jogamp] <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |