small drawing

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

small drawing

keith
I am attempting to move my code from an older version to the current version using NEWT and SWT. When I start the application, it draws in a small area in the bottom left of the shell/Composite/Canvas. The whole application works and appears there, but this is not useful. I want a full screen. Screen shot attached.

I'm not sure how much code to include

      Shell parent = App.getDisplay().getActiveShell();
      example.display = parent.getDisplay();
      example.shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
      App.addShellEscape(example.shell);
      example.shell.setLayout(new FillLayout());
      example.shell.setText(App.getAppResources().getString("VR.title")); // $NON-NLS-1$

      Composite joglComp = new Composite(example.shell, SWT.NONE);
      joglComp.setLayout(new FillLayout());
      // get our framework
      final JoglCanvasRenderer canvasRenderer = new JoglCanvasRenderer(example);
      canvasRenderer.setCamera(new Camera()); // set up in App3d.initExample
      
      example._canvas = new JoglNewtSwtCanvas(settings, canvasRenderer, joglComp, SWT.NONE);
      example._canvas.setLayout(new FillLayout());
Reply | Threaded
Open this post in threaded view
|

Re: small drawing

gouessej
Administrator
Hi

Please show a FULL example, a sscce: http://sscce.org.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: small drawing

philjord
Keith,
It looks like the first thing to ensure is that this is not just purely the swt layout failing.

So it would be good to post some information about how you can show it's related to JoglNewtSwtCanvas specifically not just any component that's added, so perhaps an example showing a blue colored Canvas alone with no Jogl in it at all.

So replace these line with a boring canvas and show the image of the screen being filled as you want, (or if not make it so it does and test Jogl again)

example._canvas = new JoglNewtSwtCanvas(settings, canvasRenderer, joglComp, SWT.NONE);
example._canvas.setLayout(new FillLayout());

Next thing is that this issue is not related to Java3D at all but in fact Jogl itself, these are 2 different things, one built on the other. I suspect a forum admin will move this issue across to Jogl at some point.

Finally the sscce Julien refers to needs to be so simple that anyone on the forum who wants to help can just paste the sample code into eclipse with a few clicks and run it and get the same issue.

So that generally means you need a single class of code showing the issue (like you have) but all the code required to show it, and as much setup instruction as you can give (many paragraphs is good).

Once you do that generally you'll get a quick response from someone who can help, or tell you what to do next.

Phil.
Reply | Threaded
Open this post in threaded view
|

Re: small drawing

gouessej
Administrator
JoglNewtSwtCanvas comes from JogAmp's Ardor3D Continuation, it extends NewtCanvasSWT. I agree with philjord's suggestion, let's make your example work with a dumb org.eclipse.swt.widgets.Canvas first and then with NewtCanvasSWT.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: small drawing

keith
Sorry, I did not read your responses until just before posting this example. It is taken from the code as it exists as much as possible. I will try your suggestions after I post this example.threeD_test.zip
Reply | Threaded
Open this post in threaded view
|

Re: small drawing

keith
With a org.eclipse.swt.widgets.Canvas background blue, it fills the whole composite.
Reply | Threaded
Open this post in threaded view
|

Re: small drawing

keith
Same sscce, but more complete info:  threeD_test.zip

Running on a Windows 7, 64 bit machine.

plugins directory under threeD_test contains files from eclipse 1.8.0_91 add these to Project->Properties->Java Build Path->Library (file with plugins was too large to load)
06/29/2016  02:02 PM            31,762 ardor3d-awt-1.0-SNAPSHOT.jar
06/29/2016  02:02 PM         1,091,966 ardor3d-core-1.0-SNAPSHOT.jar
06/29/2016  02:02 PM           158,717 ardor3d-effects-1.0-SNAPSHOT.jar
06/29/2016  02:02 PM           145,871 ardor3d-extras-1.0-SNAPSHOT.jar
06/29/2016  02:02 PM             3,987 ardor3d-jinput-1.0-SNAPSHOT.jar
06/29/2016  02:02 PM           184,737 ardor3d-jogl-1.0-SNAPSHOT.jar
06/29/2016  02:02 PM            16,002 ardor3d-jogl-awt-1.0-SNAPSHOT.jar
06/29/2016  02:02 PM             7,421 ardor3d-jogl-swt-1.0-SNAPSHOT.jar
06/29/2016  02:02 PM           154,125 ardor3d-math-1.0-SNAPSHOT.jar
06/29/2016  02:02 PM             7,630 ardor3d-savable-1.0-SNAPSHOT.jar
06/29/2016  02:02 PM            21,363 ardor3d-swt-1.0-SNAPSHOT.jar
06/29/2016  02:02 PM           168,503 ardor3d-terrain-1.0-SNAPSHOT.jar
06/29/2016  02:02 PM           509,236 ardor3d-ui-1.0-SNAPSHOT.jar
06/29/2016  02:02 PM           345,605 gluegen-rt.jar
07/05/2016  03:17 PM         2,256,213 guava-18.0.jar
05/19/2016  10:02 AM           214,860 jinput.jar
07/06/2016  11:06 AM           240,721 jogl-all-natives-windows-amd64.jar
06/29/2016  02:02 PM         3,414,448 jogl-all.jar
05/19/2016  10:02 AM           113,716 org.eclipse.core.commands_3.7.0.v20150422-0725.jar
05/19/2016  10:02 AM            78,923 org.eclipse.core.runtime_3.11.1.v20150903-1804.jar
05/19/2016  10:02 AM           357,662 org.eclipse.emf.common_2.11.1.v20160208-0816.jar
05/19/2016  10:02 AM         1,190,187 org.eclipse.emf.ecore_2.11.2.v20160208-0816.jar
05/19/2016  10:02 AM           111,675 org.eclipse.equinox.common_3.7.0.v20150402-1709.jar
06/23/2016  12:25 PM           182,901 org.eclipse.equinox.registry_3.6.0.v20150318-1503.jar
05/19/2016  10:02 AM         1,189,869 org.eclipse.jface_3.11.1.v20160128-1644.jar
05/19/2016  10:02 AM         1,307,562 org.eclipse.osgi_3.10.102.v20160118-1700.jar
05/19/2016  10:02 AM         2,748,959 org.eclipse.swt.win32.win32.x86_64_3.104.2.v20160212-1350.jar

In run configuration:

Project: threeD_test
Main class: com.neighborhoodinnovations.App
VM Arguments:
-XX:MaxDirectMemorySize=1024m
-XX:+HeapDumpOnOutOfMemoryError
-Xms512m
-XX:HeapDumpPath=C:\Users\Keith\git\land-mentor\land-mentor
-Dsun.java2d.noddraw=true
-Dsun.java2d.opengl=true
-Dsun.java2d.d3d=false
Reply | Threaded
Open this post in threaded view
|

Re: small drawing

gouessej
Administrator
Hi

I think that the viewport doesn't get resized, it explains why the canvas seems to remain tiny. I'll suggest a fix as soon as possible.

Your example would have been easier to use if you had used Maven but it's my fault, I haven't put JogAmp's Ardor3D Continuation into any Maven repository yet.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: small drawing

gouessej
Administrator
In reply to this post by keith
I advise you to modify JoglNewtSwtCanvas so that it uses this commented workaround:
https://github.com/gouessej/Ardor3D/blob/master/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtWindow.java#L325
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: small drawing

Keith Willenson
I copied the file in the link into com/ardor3d/framework/jogl. I also needed to copy DisplaySettings.java into the same directory. (unimportant: clicking on the link did not work, cutting and pasting the link did)

When I try to compile I get the following error:

 C:\Users\Keith\git\land-mentor\land-mentor\src\com\ardor3d\framework\jogl\JoglNewtWindow.java:346: error: cannot access GLContext
       [javac]             _canvasRenderer.setContext(getContext());
       [javac]                            ^
       [javac]   class file for javax.media.opengl.GLContext not found

which baffles me since GLContext is imported as
import com.jogamp.opengl.GLContext;

moving glugen-rt.jar and jogl-all.jar above or below the ardor-*SNAPSHOT.jar does not seem to affect anything.
Reply | Threaded
Open this post in threaded view
|

Re: small drawing

gouessej
Administrator
The current version of JogAmp's Ardor3D Continuation doesn't use "javax.media.opengl.GLContext", it uses "com.jogamp.opengl.GLContext" from JOGL 2.3.2. Please use the very latest source code available on Github:
https://github.com/gouessej/Ardor3D

Please use Maven to build this engine, it picks the right version of JOGL as you can see here:
https://github.com/gouessej/Ardor3D/blob/master/pom.xml#L273

Your JARs (especially jogl-all.jar) probably come from an older version of JOGL which isn't compatible with the latest version of JogAmp's Ardor3D Continuation.

I'm not sure that my explanation was clear. You have to insert the quoted code from JoglNewtWindow into JoglNewtSwtCanvas and to uncomment it to solve your problem.

I cannot fix any home made build system and you'll always have troubles if you try to build JogAmp's Ardor3D Continuation with the wrong versions of its third party dependencies (including JOGL). Please use Maven, it's easy to use, it's the recommended way of building this engine and it's explained in the user guide. I don't encourage you to modify the package names, it just drives harder the update of the engine within a project.

Edit.: If you don't want to use Maven to build the engine, it's up to you to update the third party dependencies. Look at this section of the tutorial for Eclipse:
https://gouessej.wordpress.com/2014/11/22/ardor3d-est-mort-vive-jogamps-ardor3d-continuation-ardor3d-is-dead-long-life-to-jogamps-ardor3d-continuation/#eclipse
I advise you to download anew jogamp-fat.jar, use the link in the tutorial. Then you'll have the right version to make it work and you won't have to worry about managing the native libraries by yourself. jogl-all.jar and gluegen-rt.jar aren't enough.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: small drawing

keith
Modified JoglNewtSWTCanvas.java with the following code:

import com.jogamp.newt.event.WindowAdapter;
import com.jogamp.newt.event.WindowEvent;

 public void init() {
        if (_inited) {
            return;
        }

        // Make the window visible to realize the OpenGL surface.
        setVisible(true);
        if (getNewtWindow().isRealized()) {
         // start new code here
          final GLWindow _newtWindow = getNewtWindow();
          _newtWindow.addWindowListener(new WindowAdapter() {
 
                 public void windowResized(final WindowEvent e) {
                 _newtWindow.invoke(true, new GLRunnable() {
               
                 @Override
                 public boolean run(GLAutoDrawable glAutoDrawable) {
                 _canvasRenderer.getCamera().resize(_newtWindow.getWidth(), _newtWindow.getHeight());
                 _canvasRenderer.getCamera().setFrustumPerspective(_canvasRenderer.getCamera().getFovY(),
                 (float) _newtWindow.getWidth() / (float) _newtWindow.getHeight(),
                 _canvasRenderer.getCamera().getFrustumNear(),
                 _canvasRenderer.getCamera().getFrustumFar());
                 return true;
                 }
                 });
                 }
            });
            // end new code here
            _canvasRenderer.setContext(getNewtWindow().getContext());
            getNewtWindow().invoke(true, new GLRunnable() {
                @Override
                public boolean run(final GLAutoDrawable glAutoDrawable) {
                    _canvasRenderer.init(_settings, true);// true - do swap in renderer.
                    return true;
                }
            });
            _inited = true;
        }
    }

Compiled with maven.
Linked new jars and jogamp-fat.jar to threeD_test
There was no change in display behavior.
Reply | Threaded
Open this post in threaded view
|

Re: small drawing

gouessej
Administrator
Hi

Please reproduce your bug by modifying this example:
https://github.com/gouessej/Ardor3D/blob/master/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtSwtExample.java

Put your modified example into a new bug report here:
https://github.com/gouessej/Ardor3D/issues

I'll do what I can in the little spare time I have.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: small drawing

keith
Once I added newResizeHandler it drew correctly. So the problem was that the camera was not at the correct size, etc. Setting camera size and frustrumPerspective before shell.open also works since my shell can not be resized.

Thanks for the help.

Keith

 canvas1.addControlListener(newResizeHandler(canvas1, canvasRenderer1));

 static ControlListener newResizeHandler(final JoglNewtSwtCanvas swtCanvas, final CanvasRenderer canvasRenderer) {
        final ControlListener retVal = new ControlListener() {
            @Override
            public void controlMoved(final ControlEvent e) {}

            @Override
            public void controlResized(final ControlEvent event) {
                final Rectangle size = swtCanvas.getClientArea();
                if ((size.width == 0) && (size.height == 0)) {
                    return;
                }
                final float aspect = (float) size.width / (float) size.height;
                final Camera camera = canvasRenderer.getCamera();
                if (camera != null) {
                    final double fovY = camera.getFovY();
                    final double near = camera.getFrustumNear();
                    final double far = camera.getFrustumFar();
                    camera.setFrustumPerspective(fovY, aspect, near, far);
                    camera.resize(size.width, size.height);
                }
            }
        };
        return retVal;
    }
Reply | Threaded
Open this post in threaded view
|

Re: small drawing

gouessej
Administrator
Thank you for sharing your findings. I can still quote it in the tutorial.
Julien Gouesse | Personal blog | Website