Multiple Windows/Canvases & Inversion of Control

I'm trying to find a way to create and manage separate multiple windows.  With which displays (LWJGL or JOGL, Native or AWT canvas, etc…) is this possible?  Can JME3 simultaneously create and use both an LWJGL and a JOGL renderer in separate windows, in the same JVM?



If this is somehow possible, the way I would ideally use it is something like:




displayConfig1 = new LWJGLNativeConfiguration(...)
window1 = new JMEWindow(displayConfig1, audioConfig, timeConfig, inputConfig, mediaResourcesConfig, new Application() {
  public void init(Display d) { .. }
  public void updateInput(Input input, float tpf) { ...}
  public void update(float tpf) { ...}
  public void render(Display display, float tpf) { ...}
  public void destroy() { ... }
});


displayConfig2 = new JOGLAWTConfiguration(...)
window2 = new JMEWindow(displayConfig2, ..., application2);

//JMEAWTPanel extends JPanel
panel1 = new JMEAWTPanel(displayConfig3, ...);

panel2 = new JMESWTPanel(...)



(the displayConfigX may need further decomposed into several classes.  one would share the commonly used display/rendering options, and others would be more specific to the particular instantiation.)

Basically, hyperslicing some of the Application and related code into smaller classes that can be used more flexibly.

So any static parts of JME would need dynamic-ized to allow spontaneous and multiple instantiations.  I know this restriction exists in JME2, but I haven't determined whether (and if where) JME3 operates statically also.  And is there any static-ness inside the latest versions of LWJGL or JOGL (which JME can't really do anything about)?

Also, this will allow more of an "inversion of control" or "dependency injection" architecture.  With the right set of component classes, an application or game can be somewhat "auto-wired".

http://picocontainer.org/introduction.html
http://www.springsource.org/about
http://en.wikipedia.org/wiki/Inversion_of_control

jME3 for the most part doesn't have any static classes. Even the resource manager is an instance class. So, you should have no problem starting multiple windows with 3D display. Though one integral component that has no been implemented yet, is context sharing which is required if you want to render the same scene in multiple windows.


And is there any static-ness inside the latest versions of LWJGL or JOGL (which JME can't really do anything about)?

Yes, LWJGL's Display class is static- only one display can be created once. If using a display parented to a canvas, only one canvas can be created. The only way to have multiple windows with LWJGL is to use AWTGLCanvas, which seems to be deprecated.

Hi,



I also want to create multiple canvases in JME2 which works pretty well. I use multiple Canvases to render multiple views of the same scene. However, I use JMECanvasImplementor which posesses the method


public void resizeCanvas(int newWidth, int newHeight) {
        final int fWidth = newWidth <= 0 ? 1 : newWidth;
        final int fHeight = newHeight <= 0 ? 1 : newHeight;
        Callable<?> exe = new Callable<Object>() {
            public Object call() {
                if (renderer != null) {
                    renderer.reinit(fWidth, fHeight);
                    height = fHeight;
                    width = fWidth;
                }
                return null;
            }
        };
        GameTaskQueueManager.getManager().getQueue(GameTaskQueue.RENDER).enqueue(exe);
    }



For me this means, that whenever my canvas is changed in size, the renderer is reinit. Now, of course, I just have ONE renderer which is used to render let's say, the x- y- and z view in 3 canvases. During this render I have to set 3 times the camera etc. In my optionion this means that I also have to

renderer.reinit(fWidth, fHeight);



each canvas in the render queue, no matter if canvas size has changed or not because all my 3 canvases could be different in size. Is this correct? Is this logical? Is this not a performance problem?

Thanks

Sorry but I totally forgot how jME2's canvas system works. You might have more luck asking on the troubleshooting or general boards.