Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (636)
Games in Android Showcase (178)
games submitted by our members
Games in WIP (688)
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  
  Faster tile creation  (Read 1425 times)
0 Members and 1 Guest are viewing this topic.
Offline weston
« Posted 2004-08-02 04:17:33 »

I'm writing a game framework that I will use for making java2D games (I will do an jogl or lwjgl version later, havn't decided which yet), and for tiled games I use all the tiles for a given location from a single image (rm2k chipsets actualy). Right now I am breaking this image into pieces when the level is loaded and storing all the tile images in a BufferedImage[][], this allows me to draw my maps plenty fast, but it takes a bit too much time to do the breaking it into tiles part. Is there a way where I can get similar rendering speeds without such a big load time? here is my code for breaking the image into tiles:

private void createTileImages()
    Graphics2D g2;
    GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
    for (int row = 0; row < tileImages.length; row++)
      for (int col = 0; col < tileImages[row].length; col++)
        tileImages[row][col] = gc.createCompatibleImage(Game.TILE_WIDTH, Game.GAME_HEIGHT, Transparency.BITMASK);
        g2 = tileImages[row][col].createGraphics();
        g2.drawImage(image, 0-col*Game.TILE_WIDTH, 0-row*Game.TILE_HEIGHT, null);

for(int i = 1; i > 0; i++)
     System.out.println(i+" cups of java downed");
Offline oNyx

JGO Coder

Medals: 2

pixels! :x

« Reply #1 - Posted 2004-08-02 05:59:24 »

You draw the whole image each time. The version of drawImage which takes a target and a source rect should be somewhat faster.


弾幕 ☆ @mahonnaiseblog
Offline weston
« Reply #2 - Posted 2004-08-02 06:43:03 »

Ok, I'll give that a try and see how it does. Tommorow I'm Leaving to New York for 10 days Grin so I won't be responding about the results any time soon Sad.

for(int i = 1; i > 0; i++)
     System.out.println(i+" cups of java downed");
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline dranonymous

Junior Devvie

Hoping to become a Java Titan someday!

« Reply #3 - Posted 2004-08-02 12:03:36 »

oNyx - Why is the other drawImage slightly faster?  I looked at the javadoc between the different methods and it doesn't seem to mention anything about it being faster.
Offline Abuse

JGO Ninja

Medals: 42

falling into the abyss of reality

« Reply #4 - Posted 2004-08-02 12:30:40 »

oNyx - Why is the other drawImage slightly faster?  I looked at the javadoc between the different methods and it doesn't seem to mention anything about it being faster.

I would presume because that method is manually specifying the clip rectangle, where as your method requires the API to work it out for itself.

I wouldn't expect the difference between the two to be large however. (a few extra if's per image draw, thats all)

btw, why are you breaking the source image into tiles anyway?
I would imagine rendering 100s of different tiles should be slower than rendering many different portions of the same image.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here!
Offline pepe

Junior Devvie

Nothing unreal exists

« Reply #5 - Posted 2004-08-02 12:37:20 »

afair, Trembovetski said one time that using getSubimage(int x, int y, int w, int h)  on a BufferedImage would return an object pointing on the same source data.
I expect that to be way faster to draw under GL pipeline (no texture switching) but i think it might also help actually.
Moreover, it would reduce memory consumption, fragmentation in ram and vram, and would give almost non perceptible tile creation time.
Worth a try, imho.

Home page:
GoSub: java2D gamechmark
Offline weston
« Reply #6 - Posted 2004-08-02 13:03:37 »

whether I draw hundreds of diferent tiles or different areas of a single source image, I'm still drawing 16x16 pixels so I thought the speed would be the same... that doesn't mean I think thats the best way of doing it though, thats why I was looking for a new way Grin Sounds like the alternate draw method or getSubImage() could work well, sad I won't be able to try for 10 days though, I'm leaving in about 15 minutes...

for(int i = 1; i > 0; i++)
     System.out.println(i+" cups of java downed");
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Dwinin (75 views)
2015-11-07 13:29:08

Rems19 (81 views)
2015-10-31 01:36:56

Rems19 (79 views)
2015-10-31 01:32:37

williamwoles (107 views)
2015-10-23 10:42:59

williamwoles (93 views)
2015-10-23 10:42:45

Jervac_ (112 views)
2015-10-18 23:29:12

DarkCart (137 views)
2015-10-16 00:58:11

KaiHH (118 views)
2015-10-11 14:10:14

KaiHH (158 views)
2015-10-11 13:26:18

BurntPizza (173 views)
2015-10-08 03:11:46
Rendering resources
by Roquen
2015-11-13 14:37:59

Rendering resources
by Roquen
2015-11-13 14:36:58

Math: Resources
by Roquen
2015-10-22 07:46:10

Networking Resources
by Roquen
2015-10-16 07:12:30

Rendering resources
by Roquen
2015-10-15 07:40:48

Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11 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!