Hi guys,
I have been using JME for some time now and just love it. When I have questions, I usually find the answers in the forum. Unfortunately, not today.
My JME project is embedded in a swing application. I had no problem in the past using the Canvas Context and the performance has always been great.
Lately though I needed to have the possibility to have modular JDialog windows with different view to the JME World. So I switched and started to use the Awt context.
It all works… except that I now have a major performance issue with that context (AWT). I have a FPS of 3-9, instead of over 100 when I was using the Canvas context. I guess I must be doing something wrong… though the only code I changed was this :
[java]
if (!canvasRendered) {
settings.setCustomRenderer(AwtPanelsContext.class);
setSettings(settings);
start();
SwingUtilities.invokeLater(new Runnable(){
public void run(){
AwtPanelsContext ctx = (AwtPanelsContext) getContext();
awtPanel = ctx.createPanel(PaintMode.Accelerated);
awtPanel.setPreferredSize(new Dimension(500, 500));
panel.add(awtPanel);
ctx.setInputSource(awtPanel);
viewPanel = awtPanel;
}
});
}
else {
setSettings(settings);
createCanvas();
JmeCanvasContext ctx = (JmeCanvasContext) getContext();
ctx.setSystemListener(this);
Dimension dim = new Dimension(500, 500);
ctx.getCanvas().setPreferredSize(dim);
panel.add(ctx.getCanvas());
}
[/java]
You guys would be great to point my silly mistake, if there is any…
Here are 2 screenshots
AWT : http://www.aifuture.com/images/awt.png
Canvas : http://www.aifuture.com/images/canvas.png
Well the awt panels do cause more overhead due to the data copying to awt but this sounds a bit extreme… Sure theres no other overhead in the app where you create the awt panels?
Can you try the other awt panel paint modes and see if it helps?
Does the jME SDK also running slow for you? You can switch between awt panel and canvas mode in the options.
Thanks a lot for trying to help me.
If you are talking about the option in the SDK : Use Heavyweight Canvas, it’s 30fps when it’s checked and 15 when it isn’t. Or is there another option that I haven’t found for switching between canvas/awt ?
I have tried the 3 paint modes without more success (same performance)… On your computers, do you have a better performance when you use AWT panels ?
Again, thanks for helping me out !
@zothicus: Yes, on my PC it runs slightly slower when in AWT panels mode, but not with the difference you’re experiencing. When the “heavyweight canvas” option is unchecked in the SDK, then the AWT panels are used for display. Perhaps you can try maximizing the OpenGL Window in the SDK to see if the performance difference is magnified?
Hi Momoko Fan,
I have maximized the openGL window and it dropped to 5fps. When in full screen, it goes to 3fps… Crazy eh ?
I do not have such an old PC, and canvas rendering runs fine…
@zothicus: What video card are you using? Do note that the primary difference between AWT panels and canvas is that AWT panels transfer the screen image back to the CPU for rendering, this can significantly stress the AGP/PCIe bus. To have 1080p rendering at 60 fps with AWT panels requires at least a 0.5 GB/s transfer rate on the bus, not taking into account other transfers that are happening such as textures or models.
I have a NVIDIA GeForce 310M.
If it’s a video card problem, I’ll be happy knowing I did not do something wrong. Though disappointed in the fact that a “decent” PC can’t run the application with the AWT mode.