Login  Register

Reshape Problem Using NewtCanvasSWT

Posted by rhatcher on Oct 04, 2012; 7:27pm
URL: https://forum.jogamp.org/Reshape-Problem-Using-NewtCanvasSWT-tp4026385.html

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"?

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?