www.jpct.net
jPCT - a 3d engine for Java => Support => Topic started by: qjvictor on December 09, 2006, 12:58:28 am
-
We developed a game with web start, the problem is that it seems the jPCT takes so much cpu and memory.
I think it is not the problem caused by my code. because I access http://www.jpct.net/demos.html and click some very simple demos,
it also takes much cup and memory.
Anybody has solution for this issue?
Thanks.
-
Hello
what do you mean by "so much"? What is the complexity of your environment? And what renderer are you using?
-
Use sleep between renderings. I do rendering 25 times per minute and it only uses 2,3 percent of CPU (opengl mode)
-
Thanks.
You mean in the loop to render the screen, use Thread.sleep?
I will try.
Thanks anyway.
-
I use it like this
//fps.. like 25
int sleepTime = 1000 / fps;
long first = System.currentTimeMillis();
long second = 0;
long actualSleepTime = 0;
while (bRender) {
//do some stuff in world here
buffer.clear();
world.renderScene(buffer);
world.draw(buffer);
buffer.update();
buffer.displayGLOnly();
second = System.currentTimeMillis();
actualSleepTime = sleepTime - (second - first);
if (actualSleepTime < 0) {
actualSleepTime = 0;
}
try {
Thread.sleep(actualSleepTime);
}
catch (InterruptedException ie) {}
first=second;
}
-
The problem is that I must render the screen in every 10 ms.
Maybe that's the reason the jpct eats so much cpu.
-
There can also be other reasons, like complex objects you are rendering (lot of polygons)...
-
It eats up what you are giving to it. The demos are designed to run at full speed, which results in 100% cpu usage on a single core machine. If you don't want that, render less frames. As said, at a sleep if possible. And how much is much? You may try to use Config.saveMemory=true to save seom memory at the cost of...well, of almost nothing. Just try it and see if it helps.