Running two SimpleApplication side-by-side


I am currently working on a project which needs two jme3 SimpleApplication running side-by-side in the same program. I explain :

In theory, the first of these two applications should have several SceneProcessors rendering the same scene from different angles on textures. Each of these textures should be mapped onto quads in the second application, and those quads should be rendered with the same mechanism (SceneProcessor, but copying the render into bytebuffer this time, in order to display them).

I must keep both of the two applications because they might not be running on the same machine (and textures would cross the network, obviously). I know this project seems quite odd, but it’s not my biggest problem, because when I came to do some testing, I encounter this :

If I create a SimpleApplication, add my processor, a simple cube into the scene, retrieve the bytebuffer containing the render and display it into a JFrame, there is no problem, it’s working great.

But if I try to create a second SimpleApplication (again, in the same program), and do the same thing (without using render to texture or anything else, just creating a simple textured cube), I don’t see my cube but a white quad !

Here is a screenshot (I make both cubes rotate) :

I use some custom classes to create the SceneProcessors and the SimpleApplication, and can post them with a demo class if necessary.

I know jME hasn’t been designed for this kind of purpose (at all), but I still hope someone has already try some similar manipulation, and could give me a hand on this.

Thanks in advance,


Others can speak more specifically, but I think if you try to run two SimpleApplications in the same JVM then you will have issues. I believe there are things about it that assume exclusive access to process resources… I could be wrong.

Anyway, since your final use-case seems to be running them in separate processes then you should start there. There should be no issue in that case (I frequently run multiple JME apps at the same time).

Yeh, one application can only get one OpenGL context, a limitation that will be lifted in lwjgl 3.0. Still you can use multiple output windows using the awt panels (see the corresponding test class).

Hmm, that’s not good news for me… Because even if the two SimpleApplication might be running on separate machines, they must run as well on the same machine…

Anyway, thank you very much for answering, I know it’s no use to persevere that way !

You can run two SimpleApplications on the same machine, just not in the same JVM. (Which is pretty much exactly what I said above.)

Seriously, I’ve started at least four separate Mythruna clients at one point and it worked just fine other than my GPU groaning under the strain.

Yep, sorry I didn’t mention the two SimpleApplications were originally packaged into a unique graph system (where one SimpleApplication would be one node of the graph), so running into the same JVM. Because two nodes can be linked across the network, the two SimpleApplication might be running on two differents machines (and JVM), but for obvious performance reasons, it is preferable to keep the two SimpleApplication on the same machine (I hope this is clear :? !)

I thought about a way to ‘share’ one SimpleApplication between multiple scenes (and their camera) that might work, so it would solve my problem.

Thanks again for answering, it is really nice to see such an active and friendly community ! :slight_smile:

I think the performance of two java applications side-by-side should not differ too much from having the code in one application unless one of them does so few things that the normal “java maintenance” really comes to play. The, lets say 2-3MB for the JVM and stuff can’t be so bad if some textures may even have that size, can it?

It sounds like the decomposition of your problem space is very strange. To me it sounds like this: “We have this graph of applications but they aren’t really applications because we might have more than one of them in an application.”

I think you have “things”. You may have more than one of these “things” in an application or these “things” may be spread across multiple applications. But these “things” are not SimpleApplication. SimpleApplication is just the adapter for the “thing” when it is the only “thing” in an application. Because SimpleApplication is “extending” java.exe in this case.

@pspeed said:To me it sounds like this: "We have this graph of applications but they aren't really applications because we might have more than one of them in an application."

You are right, I was using the SimpleApplication as a "world". It would have physics, sounds, multiple cameras (I use SceneProcessors to retrieve a texture and/or a bytebuffer for each of my world's cameras), but it's not really an "application".

I was about to change and represent my "world" as a list of cameras/framebuffer/viewport, a rootnode and eventually a RenderState object (I'm not sure about this list since I am very new to all this 3D stuffs !), and my wish was to find a way to attach this "world" to a SimpleApplication that would do all the treatment for 1 frame, detach it when it's done, so I could attach an other "world", etc...

I am aware this could do a lot of allocations and deallocations into the graphic card, but it's a compromise I can do.

Even if the idea seems good to me, I am not sure about the way I could implement it...

Im interested in this problem. I am trying the same thing. I am rendering a foot in an simple application. However I need 2 applications in their own panel for each foot and creating 2 simple applications crashes my program. How would you guys handle this?

Worse case I can put both feet in the same simple application but i prefer the separation…

Thanks in advance

Application == exe

Application != window

There could be ways to have more than one window in an application but there will never be a way to have more than one application in an application.

Also, what do you mean by “foot” and why would you want an application per foot?

Yes I want to have two panels side by side that each has its own application per foot.

You have to understand how this sounds to me: “I want an application with two applications in it.”

It’s like “I want a car with two cars in it.” It just doesn’t make any sense, really.

KK i get what you mean now. I guess a different question is can I have 1 applications with multiple canvases in their own panels?

See TestAwtPanels