JME3 Unified Renderer - Canvas Use Issue

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

JME3 Unified Renderer - Canvas Use Issue

dardzull@yahoo.com
How do I get a canvas of some sort (JoglNewtCanvas, JoglCanvas, etc.) out of JME3 so that I can put it into a JFrame?  The following code lets me get a canvas out that does not render.

I have tried:

----------------
public class appTest extends SimpleApplication
{
    public static void main(String[] args)
    {
            AppSettings settings = new AppSettings(true);

            settings.setHeight(480);
            settings.setWidth(640);
            settings.setRenderer("JOGL");
            settings.setCustomRenderer(JoglNewtCanvas.class);

            final appTest app = new appTest();
            app.setShowSettings(false);
            app.setSettings(settings);
            app.start();

            SwingUtilities.invokeLater(new Runnable()
            {
                public void run()
                {
                    final JoglNewtCanvas ctx = (JoglNewtCanvas) app.getContext();
                    ctx.getCanvas().setBounds(0, 0, app.settings.getWidth(), app.settings.getHeight());

                    NewtCanvasAWT canvas = ctx.getCanvas();
                    canvas.setVisible(true);
                   
                   JFrame jFrame = new JFrame("Screen");
                   jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   jFrame.add(canvas);
                   jFrame.setSize(app.settings.getWidth(), app.settings.getHeight());
                   jFrame.setVisible(true);
              }
         }
    }
    @Override
    public void simpleInitApp()
    {
    }
}
----------------

But it just gives a blank screen.  

I also tried using JoglCanvas with the following changes for the renderer and it just crashed out with a Class Cast Exception.

----------------

       settings.setCustomRenderer(JoglCanvas.class);

....

            final JoglCanvas ctx = (JoglCanvas) app.getContext();
            ctx.getCanvas().setBounds(0, 0, app.settings.getWidth(), app.settings.getHeight());
             Canvas canvas = ctx.getCanvas();

----------------


Any help is appreciated.

Reply | Threaded
Open this post in threaded view
|

Re: JME3 Unified Renderer - Canvas Use Issue

gouessej
Administrator
Hi

You can easily do it with Ardor3D as you can see here.

Please post the whole class cast exception you get. You should have a look at existing examples here. This example shows how to use JMonkeyEngine 3 with several canvases in a JFrame.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JME3 Unified Renderer - Canvas Use Issue

dardzull@yahoo.com
gouessej wrote
Hi

You can easily do it with Ardor3D as you can see here.

Please post the whole class cast exception you get. You should have a look at existing examples here. This example shows how to use JMonkeyEngine 3 with several canvases in a JFrame.
That JME3 example works in windows, but not the RPI (no display).  THanks.  However when i try to get the GLCanvas there still runs the issue of getting the following error:

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.media.nativewindow.DefaultGraphicsConfiguration cannot be cast to com.jogamp.nativewindow.awt.AWTGraphicsConfiguration
        at javax.media.opengl.awt.GLCanvas.chooseGraphicsConfiguration(GLCanvas.java:1096)
        at javax.media.opengl.awt.GLCanvas.addNotify(GLCanvas.java:529)
        at com.jme3.system.jogl.JoglAbstractDisplay$1.addNotify(JoglAbstractDisplay.java:98)
        at java.awt.Container.addNotify(Container.java:2769)
        at java.awt.Window.addNotify(Window.java:770)
        at java.awt.Frame.addNotify(Frame.java:487)
        at java.awt.Window.pack(Window.java:807)
        at appTest$1.run(appTest.java:132)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721)
        at java.awt.EventQueue.access$200(EventQueue.java:103)
        at java.awt.EventQueue$3.run(EventQueue.java:682)
        at java.awt.EventQueue$3.run(EventQueue.java:680)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:691)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

Reply | Threaded
Open this post in threaded view
|

Re: JME3 Unified Renderer - Canvas Use Issue

gouessej
Administrator
Runiter already had the same problem under Mac a few days ago. Please write a bug report about that.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JME3 Unified Renderer - Canvas Use Issue

Xerxes Rånby
In reply to this post by dardzull@yahoo.com
Dardzull wrote
How do I get a canvas of some sort (JoglNewtCanvas, JoglCanvas, etc.) out of JME3 so that I can put it into a JFrame?  The following code lets me get a canvas out that does not render.
...
public class appTest extends SimpleApplication
{
...
                    NewtCanvasAWT canvas = ctx.getCanvas();
                    canvas.setVisible(true);
                   
                   JFrame jFrame = new JFrame("Screen");
...

Any help is appreciated.
I assume you run into rendering/exception issues on the raspberry pi:
AWT-OpenGL and hence Swing interoperability code is currently unsupported on the raspberry pi.
https://jogamp.org/bugzilla/show_bug.cgi?id=626

The current  way to use JogAmp JOGL on the Raspberry Pi is to use the NEWT GLWindow. We use NEWT to solve windowing situation because AWT is not available on all platforms.

To initialize a NEWT GLWindow use:
GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2ES2));
GLWindow glWindow = GLWindow.create(caps);
glWindow.setTitle("Raw GL2ES2 Demo");
glWindow.setSize(width,height);
glWindow.setUndecorated(false);
glWindow.setPointerVisible(true);
glWindow.setVisible(true);
Demo code from, found in jogl-demos: http://labb.zafena.se/?p=547

On the RaspberryPi AWT is running but on an unaccelerated surface hence we gets refused to connect OpenGL rendering output by the libEGL on the Pi because libEGL expects a Broadcom driver specific "dispmanx" native surface, something that the AWT surface is-not.

Heads-up: BroadCom are considering switching their driver from the dispmanx API to OpenWF http://www.khronos.org/openwf/
this *rumor* got  mentioned on the http://elinux.org/RPi_VideoCore_APIs RaspberryPi wiki and originate from some loose mumblings by one of the raspberry pi forum administrators.
Reply | Threaded
Open this post in threaded view
|

Re: JME3 Unified Renderer - Canvas Use Issue

gouessej
Administrator
Xerxes, why do some people get the same exception even under Mac OS X 10.6.8?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JME3 Unified Renderer - Canvas Use Issue

Xerxes Rånby
This post was updated on .
gouessej wrote
Xerxes, why do some people get the same exception even under Mac OS X 10.6.8?
That I do not know and is unable to test, I can only explain the Raspberry Pi specific use case. I do not think you can get the same exception on the two systems.

I have not seen the exception generated for the Raspberry Pi by the user so I will assume the exception was (the same as in  bug626)
Caused by: java.lang.IllegalArgumentException: Native windowing type .bcm.vc.iv (custom) not yet supported, platform reported native windowing type: .bcm.vc.iv
        at jogamp.nativewindow.NativeWindowFactoryImpl.getAWTNativeWindow(NativeWindowFactoryImpl.java:92
when the raspberry pi displayed no rendering.

I do assume that OSX work using NEWT and work according to all out current OSX unit-tests that pass for each build.

Can you try on the mac you have and create a trace log?
Reply | Threaded
Open this post in threaded view
|

Re: JME3 Unified Renderer - Canvas Use Issue

gouessej
Administrator
Xerxes Rånby wrote
I do assume that OSX work using NEWT and work according to all out current OSX unit-tests that pass for each build.

Can you try on the mac you have and create a trace log?
I'll do it tonight when I'm at home. TestCanvas should be enough to reproduce this bug.
Julien Gouesse | Personal blog | Website