Problem with NewtCanvasSWT and SWT during the GL3HelloWorld

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

Problem with NewtCanvasSWT and SWT during the GL3HelloWorld

Fafnir
I'm new to JOGL, and, for some reason, I have to begin with SWT. Here is a piece:

        public Trangles(GLCapabilities capabilities)
        {
                Display display = new Display();
                Shell shell = new Shell(display);
                shell.setLayout(new FillLayout());
                Composite composite = new Composite(shell, SWT.BORDER);
                GLWindow window = GLWindow.create(capabilities);
                NewtCanvasSWT canvas = new NewtCanvasSWT(composite, SWT.NO_BACKGROUND,
                                window);
                window.addGLEventListener(new Event());

                shell.setSize(300, 200);
                shell.open();
                canvas.setVisible(true);

                //Here I meet the problem.
                //window.setVisible(true);

                while (!display.isDisposed())
                {
                        if (!display.readAndDispatch())
                                display.sleep();
                }
                display.dispose();
        }

When I add the line "window.setVisible(true);",  the whole shader works well, and I get a red triangle in a new dialog window  with the shell still blank. I fail to mix there two window no matter I arrange the NewtCanvasSWT. Is there any method dealing with it?

Trangles.java
Reply | Threaded
Open this post in threaded view
|

Re: Problem with NewtCanvasSWT and SWT during the GL3HelloWorld

Sven Gothel
Administrator
On 04/21/2013 08:21 AM, Fafnir [via jogamp] wrote:

> I'm new to JOGL, and, for some reason, I have to begin with SWT. Here is a piece:
>
>         public Trangles(GLCapabilities capabilities)
>         {
>                 Display display = new Display();
>                 Shell shell = new Shell(display);
>                 shell.setLayout(new FillLayout());
>                 Composite composite = new Composite(shell, SWT.BORDER);
>                 GLWindow window = GLWindow.create(capabilities);
>                 NewtCanvasSWT canvas = new NewtCanvasSWT(composite,
> SWT.NO_BACKGROUND,
>                                 window);
>                 window.addGLEventListener(new Event());
>
>                 shell.setSize(300, 200);
>                 shell.open();
>                 canvas.setVisible(true);
>
>                 //Here I meet the problem.
>                 //window.setVisible(true);
>
>                 while (!display.isDisposed())
>                 {
>                         if (!display.readAndDispatch())
>                                 display.sleep();
>                 }
>                 display.dispose();
>         }
>
> When I add the line "window.setVisible(true);",  the whole shader works well,
> and I get a red triangle in a new dialog window  with the shell still blank. I
> fail to mix there two window no matter I arrange the NewtCanvasSWT. is there
> any method dealing with it?
>
> Trangles.java <http://forum.jogamp.org/file/n4028988/Trangles.java>
The unit test/demo work:
  'com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT'

Maybe it's related to the fact that you don't issue your SWT calls on the SWT
thread ?

Pls test and check our test code and check difference w/ yours. Thx.

~Sven




signature.asc (911 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problem with NewtCanvasSWT and SWT during the GL3HelloWorld

Fafnir
Hi, Sven. In "com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT", an Animator is built and the GLWindow is added to it. I'm so confused now because other basic initilizations look the same. The Eclipse report that my NewtCanvasSWT is not in used