Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (623)
Games in Android Showcase (176)
games submitted by our members
Games in WIP (676)
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 1396 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 Knight

Medals: 34

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.

BurntPizza (32 views)
2015-10-08 03:11:46

BurntPizza (17 views)
2015-10-08 00:30:40

BurntPizza (19 views)
2015-10-07 17:15:53

BurntPizza (32 views)
2015-10-07 02:11:23

KaiHH (38 views)
2015-10-06 20:22:20

KaiHH (16 views)
2015-10-06 19:41:59

BurntPizza (32 views)
2015-10-06 19:04:48

basil_ (47 views)
2015-09-30 17:04:40

shadowstryker (27 views)
2015-09-29 15:55:06

TheSpaceHedgehog (32 views)
2015-09-29 01:58: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

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36 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!