Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (686)
Games in Android Showcase (198)
games submitted by our members
Games in WIP (758)
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 better for animation?  (Read 1846 times)
0 Members and 1 Guest are viewing this topic.
Offline Graziano Mesina

Senior Newbie

« Posted 2006-09-24 13:56:37 »

Hi, I would create an animation with some frames for my game entities.

Is better to create

an Array of images
a single image that will contain all frames and then call methods
g.setClip((int)x,(int)y,image.getWidth(null) / numFrames,image.getHeight(null));         
g.drawImage(image,(int)x - frameCorrente * image.getWidth(null) / numFrames,(int)y,null);

 Huh Huh

-Montanelli-: Ma lei evadeva quasi sempre, no? <br /><br />-Mesina-: Sì, ho la fortuna di avere i polsi più grossi delle mani...
Offline fletchergames

Senior Devvie

« Reply #1 - Posted 2006-09-24 14:02:46 »

An array of images is probably better because getting a part of the image is generally slower than getting the whole image.  Also, it may make it easier for the JVM to determine what images to accellerate.
Offline trembovetski

Senior Devvie

If only I knew what I'm talking about!

« Reply #2 - Posted 2006-09-26 16:29:18 »

In some cases it's better to use a single larger image for your sprites.
It will more likely result in less overhead if this image is to be cached
in vram.

Some hw configurations only allow power of two textures, so
for example your 24x35 sprite will have to be placed into a 32x64 texture.
So if you have tons of textures like that your overhead will be
significant. But if you place all of them into a 512x512 texture,
it could be reduced.

Also, having your sptires in a single image may help with performance
as it requires less context switching for the native pipeline.
Many images:
  copy image 1 into texture 1
  copy image 2 into texture 2
  set texture 1
  render texture 1 at coord1
  set texture 2
  render texture 2 at coord2

Single image:
  copy image into texture
  set texture
  render texture at coord1
  render texture at coord2

And since setting a new texture is an expensive context switching
operaion (at least, for Direct3D), the second way is typically faster.

For software-only rendering it doesn't make that much
of a difference.

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

« JGO Spiffy Duke »

Medals: 272
Projects: 25
Exp: 18 years

Coder, Trainee Pixel Artist, Game Reviewer

« Reply #3 - Posted 2006-09-26 16:35:02 »

Interesting, it's always been the other way round in benchmarks, see the discussion here:

and bench mark here:

Generally storing lots of little images in Java2D has been faster. However, with the new opengl pipeline it makes sense in my head that sprite sheets should be efficient.

EDIT: Is there any chance that a sub-image in the new pipeline is just a reference to the old image with different texture coordiantes?


Offline trembovetski

Senior Devvie

If only I knew what I'm talking about!

« Reply #4 - Posted 2006-09-28 01:08:16 »

Is there any chance that a sub-image in the new pipeline is just a reference to the old image with different texture coordiantes?

If by "sub-image" you mean doing a drawImage of a region of larger image, then yes, in
opengl and d3d pipelines it's just a tweaking of the teture coordinates of
the same texture.

In other pipelnes it's pretty much the same thing - just different source
coordinates of corresponding blit operation (srcx,srcy,w,h) instead of 0,0,w,h -
the exact same routine is used as with copying from smaller image.
There's a bit of extra logic to figure out that this is not a scale (if src/dst width/height
are different or not).

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

roseslayer (516 views)
2016-08-06 11:43:29

roseslayer (473 views)
2016-08-06 09:43:11

xTheGamerCodes (547 views)
2016-08-04 15:40:59

xTheGamerCodes (542 views)
2016-08-04 15:40:24

orrenravid (887 views)
2016-07-16 03:57:23

theagentd (965 views)
2016-07-11 14:28:54

Hydroque (1061 views)
2016-07-06 05:56:57

Hydroque (1042 views)
2016-07-03 08:52:54

GrandCastle (858 views)
2016-07-01 09:13:47

GrandCastle (644 views)
2016-07-01 09:09:45
Rendering resources
by Roquen
2016-08-08 05:55:21

Rendering resources
by Roquen
2016-08-08 05:52:42

Rendering resources
by Roquen
2016-08-08 05:50:38

Rendering resources
by Roquen
2016-08-08 05:49:53

Rendering resources
by Roquen
2016-08-08 05:32:39

Making a Dynamic Plugin System
by Hydroque
2016-06-25 00:13:25

Java Data structures
by BinaryMonkL
2016-06-13 21:22:09

Java Data structures
by BinaryMonkL
2016-06-13 21:20:42 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‑
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!