Login  Register

Re: Reshape Problem Using NewtCanvasSWT

Posted by Sven Gothel on Oct 04, 2012; 11:28pm
URL: https://forum.jogamp.org/Reshape-Problem-Using-NewtCanvasSWT-tp4026385p4026391.html

On 10/04/2012 09:27 PM, rhatcher [via jogamp] wrote:

> Fedora 12
> JRE/JDK 7u7
> GeForce 9800 GT + NVIDIA driver 304.37
> JOGAMP/JOGL custom build from 10/02/2012 repos (RC11 in progress)
>
> This topic is an offshoot of some suggestions Sven made in
> http://forum.jogamp.org/The-Current-State-Of-JOGL-SWT-Integration-tp4026329.html.
>
> I'm trying out NewtCanvasSWT embedded in a "part" (i.e. stuffed under a tab)
> in an Eclipse4 workbench window, and it sort of works.
>
> The GLEventListener initially draws what I expect, but it doesn't reshape
> properly.  It gets a few reshape() calls when the program opens, but after
> that only display() gets called if the size of the part is changed.  FWIW the
> "updateSizeCheck" protected method in NewtCanvasSWT /is/ getting called.
>
> Also, window exposure does not trigger display() calls.
>
> I wasn't sure how to use NewtCanvasSWT so I could easily have something set up
> wrong.  This is the relevant code:
>
>     private NewtCanvasSWT _canvas ;
>     ...
>     @PostConstruct
>     public void postConstruct( Composite parent )
>     {
>         GLWindow glWindow = GLWindow.create( new GLCapabilities( null ) ) ;
>         _canvas = NewtCanvasSWT.create( parent, SWT.NO_BACKGROUND, glWindow ) ;
>
>         glWindow.addGLEventListener( new TestGLEventListener() ) ;        
>         glWindow.addKeyListener( new TestKeyListener() ) ;
>         glWindow.addMouseListener( new TestMouseListener() ) ;
>     }
>     ...
>     @Focus
>     public void setFocus()
>     {
>         // I wasn't sure what should get focus here, but the canvas seemed
> logical.
>         _canvas.setFocus() ;
>     }
>
> Should that "just work"?
Yes, that's how it should work in general - simple API.

See unit tests just using the proper SWT thread for critical SWT initialization,
which might be required for some OS.

<http://jogamp.org/git/?p=jogl.git;a=blob;f=src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java;hb=HEAD#l60>
<http://jogamp.org/git/?p=jogl.git;a=blob;f=src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aSWT.java;hb=HEAD#l57>
<http://jogamp.org/git/?p=jogl.git;a=blob;f=src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04SWT.java;hb=HEAD#l59>

Just checked the unit test demo manual
  - uncomment the following test line in jogl/make/script/tests.sh (and comment out the active one)
    testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $*

  - run: jogl/make> script/tests-x64.sh -time 10000

Yes, we have a regression, sorry. Resize and Key/Mouse input isn't
covered by a unit test yet.

Will look into it now.

>
> I'm also not getting mouse or keyboard events.  Should I be, provided the
> _canvas is getting focus?  I verified that the setFocus method is getting
> called, but I wasn't sure if I should be passing this on to the canvas or
> something else.  Or... should I be setting up the mouse and key listeners
> differently?

No, should work - see above.

~Sven



signature.asc (907 bytes) Download Attachment