Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (604)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (654)
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  
  drawImage performance weirdness - [EDIT: small images]  (Read 1407 times)
0 Members and 1 Guest are viewing this topic.
Offline Ask_Hjorth_Larsen

Junior Devvie

Java games rock!

« Posted 2005-09-14 00:27:19 »

My computer is capable of rendering a certain 800x600 image to the screen approximately 650 times per second. Now, if I render an image of size 253x253 I get framerates of 4300(!), which is reasonably close to the same time per pixel. But if I resize that Image to 252x252, the framerate drops to about 250, then increases to about 400 in about 20 seconds. Apparently only images that are sufficiently large are accelerated. Does anyone know what is going on here?

Images created with GraphicsConfiguration.createCompatibleImage(int,int,int). No pipeline is enabled. No FSEM mode. Rendering done on Canvas with bufferStrategy(2).

Using: Linux, 1200 MHz AMD Duron, GeForce440MX, JRE 1.5.0_b05.

Feel free to ask for further information if it may shed light on something. Sorry about the heavy editing of this post if you just viewed it, but I thought I might as well update it completely based on recent results.

EDIT: Clarification - when I said "resize" above, I meant selecting another size at compile-time.
Offline Ask_Hjorth_Larsen

Junior Devvie

Java games rock!

« Reply #1 - Posted 2005-09-14 15:10:08 »

I have found a workaround.

The following method
drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) 

of java.awt.Graphics is able to draw parts of images. Rendering a "small" part of a "large" image will still be fast, as long as no rescaling is done (in which case rendering would probably still be fast).
Offline trembovetski

Senior Devvie

If only I knew what I'm talking about!

« Reply #2 - Posted 2005-09-14 22:04:00 »

Which type of image? Transparent, translucent or opaque?

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

Junior Devvie

Java games rock!

« Reply #3 - Posted 2005-09-14 22:46:15 »

The image is opaque.

I tried to reproduce the problem in windows, without success. Nothing seems to happen with the framerate when I render small images. On the other hand, I get a maximum framerate of 1300 in windows, where in linux I can sometimes obtain more than 4000 fps. I guess I'll have to experiment a bit more with this.
Offline trembovetski

Senior Devvie

If only I knew what I'm talking about!

« Reply #4 - Posted 2005-09-15 21:14:35 »

Note that unless you do Toolkit.getDefaultToolkit.sync() after you
rendered the images (at the end of each frame, for example) you're measuring the speed at
which we can issue X11 calls,  which is not what you  want to measure.

X11 just queues those requests and does nothing. The sync() makes it
to flush the queue and process the requests - that is, to actually render the images.

Java2D Team

Offline Ask_Hjorth_Larsen

Junior Devvie

Java games rock!

« Reply #5 - Posted 2005-10-04 00:36:43 »

Okay, sync() didn't seem to make any difference. Am I doing something wrong? Anyway, under windows the problem is not present, but the performance is not very high either. In linux, the performance is very good, but when the images are smaller than that value, performance drops tremendously.

I tried to run a tile-based game under windows and linux, and the performance on linux was extremely low, around 10 fps when it should easily output several hundred. As mentiond above I could increase performance by simply rendering *parts* of images, but this makes for highly ugly code. I just wonder whether the huge performance difference when rendering small images is because of the driver or Java2D.

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

SHC (37 views)
2015-08-01 03:58:20

Jesse (24 views)
2015-07-29 04:35:27

Riven (44 views)
2015-07-27 16:38:00

Riven (24 views)
2015-07-27 15:35:20

Riven (27 views)
2015-07-27 12:26:13

Riven (18 views)
2015-07-27 12:23:39

BurntPizza (39 views)
2015-07-25 00:14:37

BurntPizza (48 views)
2015-07-24 22:06:39

BurntPizza (33 views)
2015-07-24 06:06:53

NoxInc (40 views)
2015-07-22 22:16:53
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 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!