VolatileImage usage

Fellas…

I’ve got a little video game and
i was facing some speed issues in high
resolutions so i thought: “why not?let’s
find out what this volatileImage stuff is all about”

The situation is the following:
Container->Canvas
BufferedImages drawing in
Buffer (BufferedImage) and then the buffer is being
drawn to the Graphics of the Canvas using
Graphics2D’s drawImage.

I knew nothing about VolatileImage so i started changing
everything i saw from BufferedImage to VolatileImage using
routines for validate() cases and contentsLost() (std procedure…)
The Result? Disastrous…(fps down 3-4 frames)

OK i have understood the redundancy of using VolatileImages
for the initial images but what about the final Buffer?
I mean it’s the image(array of bytes)that should stay in the VRAM…

So,I did it again with only the final buffer being Volatile
but the results were the same.

Tell me:
Do i have a really BIG misconseption about what a
VolatileImage is and how to use it?
Does the above structure has any potential of becoming
any faster without any big changes (e.g BufferStrategy)?

I don’t want so much a solution to my problem
comparably to how badly i want to find out
if i got straight VolatileImage.

It’s hard to day where the problem would be from what you have posted so far. Can you post the relevant code?

So you say there IS a problem…

I mean from my description i shouldn’t
face a decreasing fps but an increasing one?

I don’t think he’s saying anything about a problem with VolatileImages. In my experience, VolatileImage is alot trickier to implement properly than it would seem at first glance. Things have to be done in the right order and a FPS increase is not guaranteed or automatic especially if you don’t do things in the order VolatileImage expects.

Abuse posted a little demo called balls.jar a couple months back. I don’t know if that code is still available, but you can find an excellent thread on the subject here: http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=2D;action=display;num=1057468145;start=3#3

yeah its still around.

http://www.pkl.net/~rsc/downloads/Balls.jar

There is also a version with Ball<->Ball collision (though its not very efficient - just a little play I had)

http://www.pkl.net/~rsc/downloads/Balls2.jar

Cool demo, I’ve been wanting to start playing around with collision detection. As with the original balls demo, Balls2 seems to be a great example for pointing me in the right direction. I can’t wait to see what “Balls 3: Revenge of the Balls” will show us :P. Thanks for posting it!

prolly have a go at ‘proper’ collision detection :o

(at the moment it isn’t a true simulation of motion, just an approximation - only 1 ball is moved at a time - this can lead to balls overlaping in certain circumstances)

The solution will entail all kind of nastyness though :-/