Removed..

Removed…

Just curious why you’ve set this step manually on linux and mac? Its not always the most reliable and fastest pipeline on those platforms and besides Java 7 on linux has a new Xrender pipeline which is suppose to be even better “-Dsun.java2d.xrender=True”, so usually for linux and mac its best to use the default rendering pipeline.

Removed…

You only need one sleep call per frame. That is said allready in least 5 other threads.

Removed…


http://img855.imageshack.us/img855/4932/1327486956948.jpg

We’ve noticed.

OpenGL (and DirectX) works like this: The CPU issues commands which are put in a queue. The driver then processes these commands in order and in turn produces commands that the GPU executes. This could mean that most commands (even a buffer flip = BufferStrategy.show()) would be non-blocking, but the command queue has a limited length. If the command queue is full and you try to add a new command it will block until there is space in the queue. This means that any command that ends up in the command queue might end up blocking for a few milliseconds. However, this will only happen if the CPU is feeding commands faster than the driver and the GPU can consume them. There are a number of commands that always block though. For example reading back image data to the CPU from the GPU will almost always block, since the all commands that draw to the image has to be completed before the read back can be done.

This does not directly map to Java2D though. Java2D may be forcing additional synchronization between the GPU and the CPU depending on drivers, OS and graphics library (OpenGL, DirectX, e.t.c). Therefore it is pretty much impossible to give a clear answer to you.

Most important is that whether it is blocking or not, doesn’t make any difference to the way you should program against the gfx API.

Even when the call to drawImage(…) is non-blocking, adding a sleep(…) after it is not giving you any advantage whatsoever.

Last but not least, yes, I noticed you added ‘990ms sleep’ to your applet a while ago. It was completely unusable, rendering at barely 1fps.

Please sleep only once per frame, like everybody else!

Just because it’s a hobby, doesn’t mean that you shouldn’t at least try to follow the advice given to you, when you yourself asked for them. Besides, what’s wrong with following “best practice”, even if it’s a hobby? :slight_smile:

We certainly have.

Not necessarily because everyone else does it, but mostly to make your code less cluttered and MAINTAIN OUR SANITY while playing your games :wink:

Also keep sleep timer accuracy in certain bounds. If sleep timer resolution is x milliseconds per call. Max error with one call is most x ms but if you do 100 sleep call the worst case would be 100 * x ms per frame.

“Not broke? don’t fix it”
“Not slow? keep going”

FTFY

FTFY

Err I mean to avoid optimization since behind this is the queue was full so need sleep after every task to create space for another task.

oh yeah ;D