I brought this issue up months ago, back in 1.4.0 as a potencial problem when TRANSLUCENT VolatileImages eventually get implemented.

Now in 1.5 they finally have been I'm not seeing anything in the API that has been changed to ever make TRANSLUCENT VolatileImages work reliably.

The loop suggested in the API for ensuring a VolatileImage is draw correctly simply does not work when dealing with TRANSLUCENT images, the reason is because when performing a TRANSLUCENT blit, both the source and destination pixels contribute to the resultant pixel color.The destination pixel will therefor be effectively corrupt if you render the source image twice.

Heres the sequence of operations that causes the problem.

1) Validate VolatileImage to make sure its ok to blit.

2) blit it to the backbuffer.

3) outside event causes the VolatileImage to lose its contents.

4) contentsLost is called, and returns true.

4) so your code has to restore the VolatileImage.

5) and then re-blit it to the backbuffer. etc etc.

This loop could potencially go on forever, but for simplicity lets say it happens only twice.This still means a TRANSLUCENT image has been rendered onto the backBuffer twice, when it should have only been rendered once.This will result in incorrect pixel values in the destination.

[edit]I guess the simplest solution is to change the definition what contentsLost() returns.

Instead of a boolean indicating whether the contents has been lost since the last call to validate(),it should be changed to indicate if the contents has been lost since the last time the image was drawn?[/edit]

p.s. I assume managed BufferedImages can behave in the exact same way, as their cached copy in vram can potencially lose its contents at any time also?

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org