Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  What is VolatileImage?  (Read 2006 times)
0 Members and 1 Guest are viewing this topic.
Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Posted 2011-03-10 03:32:20 »

So what is VolatileImage exactly?
How is it different/better/worse than BufferedImage?

Offline Alan_W

JGO Knight


Medals: 8
Projects: 3


Java tames rock!


« Reply #1 - Posted 2011-03-10 06:35:35 »

In early versions of Java, BufferedImages were not hardware accelerated.  If you wanted acceleration, you used a VolatileImage, which represented an Image held in the graphics processor memory.  However as that memory is of limited size, images that hadn't been used recently got discarded to make room for new ones that needed to be drawn immediately.  Thus before you use a VolatileImage, you had to check whether it has been discarded and if so recreate it.

In later versions of java, BufferedImages were extended to have hardware acceleration.  Most useful is that when you draw a BufferedImage, it now automatically checks to see if the GPU copy has been discarded and automatically recreates it if necessary.  The end result is that nowadays there is little point to using VolatileImages, as BufferedImages offer the same performance, but with less coding.

Edit: I just looked at the other thread, which said that in some cases volatile images were still faster than bufferedimages except in fullscreen.  It looks to be graphics driver/card dependent.  It maybe that BufferedImages use slightly different graphics calls, some of which are not hardware accelerated on some platforms.  Similarly the graphics pipeline for fullscreen may fail to get hardware acceleration for some card related issue.  Possibly the card doesn't have enough memory in fullscreen mode and cannot cache all the images. Could happen if BufferStrategy is being used.  The discard algorithm that BufferedImage uses may differ from a user defined scheme used with VolatileImages.

On Java 1.4.2 there was a bug that certain window sizes rendered slowly for no apparent reason.  I added a frig that resized the window slightly if this appeared to be happening.  This was not using VolatileImages so is probably unrelated.

Time flies like a bird. Fruit flies like a banana.
Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #2 - Posted 2011-03-10 21:15:46 »

Thanks!

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline dah01

Junior Member


Medals: 7



« Reply #3 - Posted 2011-03-11 23:10:59 »

This is a really clear explanation.
Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #4 - Posted 2011-03-11 23:21:15 »

Another quick question:
What is the difference between double buffering:
-creating BufferedImage, drawing in it, drawImage() onto screen,
-using BufferStrategy.
I have only used BufferStrategy once and it doesn't seem that much different.

EDIT:Should I make another thread for this question since I can feel the replies coming in on this one?

Offline dah01

Junior Member


Medals: 7



« Reply #5 - Posted 2011-03-11 23:46:41 »

Yeah, I'd like to see code examples of an animation thread using BufferStrategy and one without.
Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #6 - Posted 2011-03-12 01:14:00 »

http://www.java-gaming.org/topics/bufferstrategy-vs-bufferedimage/23945/view.html

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (22 views)
2014-09-19 03:14:18

Dwinin (35 views)
2014-09-12 09:08:26

Norakomi (64 views)
2014-09-10 13:57:51

TehJavaDev (90 views)
2014-09-10 06:39:09

Tekkerue (44 views)
2014-09-09 02:24:56

mitcheeb (65 views)
2014-09-08 06:06:29

BurntPizza (48 views)
2014-09-07 01:13:42

Longarmx (35 views)
2014-09-07 01:12:14

Longarmx (40 views)
2014-09-07 01:11:22

Longarmx (37 views)
2014-09-07 01:10:19
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!