Jerome,
In general you would use one or the other and which one depends
on your application. BufferStrategy is probably a better one
in general because it's a more automated way of handling the
buffering stuff.
BufferStrategy uses VolatileImage underneath when it is doing
a Blt (as opposed to a Flip), so the performance of either
approach should be the same.
The reason behind your performance difference might be related
to the use of the Flip strategy. Buffer flips are gated by the
speed of the vertical refresh (which is determined by the
capabilities of your monitor and video card and the settings
of the display mode you are running in). The buffer flip
cannot go faster than that. For example, if you have an
infinitely fast game and are running at 75 Hz refresh rate, then
the fastest frame rate a flipping application could achieve is
75 FPS. Note that you can only achieve frame rates related to
the max frame rate. So, for instance, if you could theoretically
achieve 69 FPS but were running in 75 Hs refresh rate mode,
the visible frame rate would probably be 37.5 FPS (half of the
refresh rate); there are no partial frames in the world of
vertical sync.
On the other hand, if you Blt from the back buffer to the
front buffer (by using either VolatileImage and doing it
manually or by using the Blt Buffer Strategy) then you can
achive a much faster frame rate because that data copy will
happen whenever the hardware gets to it.
Although the Blt approach can be faster in some situations,
there are a couple of reasons to use Flip instead:
- Flipping avoids tearing: because the flip waits
for the vertical sync, the entire new buffer is visible
at once instead of potentially showing up during
a refresh. This rendering artifact during Blt's
is called "tearing" and can be somewhat ugly during
animation sequences. Try it in your application to
see, however.
- The process of flipping is much faster (it's just
switching a pointer instead of copying an entire
buffer's worth of pixels). So if you were actually
bogged down in rendering speed (as opposed to vsync
rates) then Flip would give you a performance
advantage over Blt.
chet.
"Blouin, Jerome" wrote:
>
> Hello!
>
> I read about the VolatileImage and BufferStrategy features and I still don't
> know witch one is best to implement an active rendering loop in a video
> game?
>
> I've developped a 2D video game and I tried the VolatileImage and
> BufferStrategy alternatively in my rendering loop. When I use the
> VolatileImage, the frames per second is higher by 7 frames compared to the
> use of a BufferStrategy.
>
> Is someone could explain me witch feature is best in my situation?
>
> Thanks!
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff JAVA2D-INTEREST". For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".