This is a pointless thread that I wanted to start to let other newbs like myself know why their animations look terrible.
I've always wondered why many java games look so crap, including mine. The animation isn't smooth even when running on state-of-the-art computers. At first I blamed the garbage collector since it pauses all threads and it's uncontrollable. But GC pauses are usually insignificantly small.
The real problem is the vertical screen retrace (the monitor refresh rate). Chet Haase showed the problem is his blog entry: <a href="http://weblogs.java.net/blog/chet/archive/2006/02/make_your_anima.html
">Make Your Animations Less Ch-Ch-Choppy</a>.
Vertical retrace is a massive problem because it can cause your images to be displayed up to 16.6 milliseconds late if the screen refreshes at 60Hz. This is noticable to the human eye.
The other problem is that it causes your animations to become 'torn' when a new image is drawn half-way through the vertical retrace, so the top half of the old screen image remains but the new one takes up the bottom half. This looks fugly to say the least.
As Chet said in his follow-up blog,
">Smooth Moves</a>:"The fix is easy for anyone writing a fullscreen Java application; applications that use the FlipBufferStrategy get this for free. When that buffer strategy copies its contents to the screen from the back buffer, it specifically waits for the vertical blank interface, and thus avoids tearing completely.
The fix is not as easy for typical windowed (non-fullscreen) applications, because there is currently no way to tell Java to wait for this interval, and there is no way for your code to know when it is a good time to go ahead with the copy. We hope to address this in a future release (I just filed a bug on it last week!), but in the meantime there is no way to get this behavior."
Anyway, i think this is one of the last things Java 2D needs to make our apps look decent, so if someone can help me find that bug & vote for it, (and politely hassle Sun's J2D team to work it out
), all the better for us.
PS: Interestingly, on my computer with the OGL pipeline enabled I get v-syncing when my BufferStrategy uses 2 buffers, but with 3 or more I lose the v-syncing.