PDA

View Full Version : Tile based game



delphiripper
12-02-2004, 10:34 AM
Hi all!

Im making a tile based game, where i have a grid of tiles (50 x 50), each with a different texture. The texture for each tile is not allways the same (it changes).

I am drawing it like this:
loop x from 1 to 50
loop y from 1 to 50
Bind texture
Draw quad

Is this the best/fastest way to do this?
I dont think that i can use a displaylist because the textures change (?)

Any oppinion is a help.

-DelphiRipper

dorbie
12-02-2004, 11:37 AM
You would be much faster packing the tiles into fewer textures and using texture coordinates to select the tile. The tiles can still change but you eliminate a lot of the texture binds.

delphiripper
12-02-2004, 12:15 PM
Combining textures wont really work... I have (potentially) 100's of textures. Pre-combining these, in all cobinations would just generate even more different textures. Combining them run-time sort of defies the purpose (optimizing).

But thanks, it could have worked :)

gmeed
12-02-2004, 12:30 PM
Originally posted by delphiripper:
Combining textures wont really work... I have (potentially) 100's of textures. Pre-combining these, in all cobinations would just generate even more different textures. Combining them run-time sort of defies the purpose (optimizing).

But thanks, it could have worked :) I don't think dorbie was recommending you cache all possible combinations. You could keep everything the way you have it now, except store each tile in a bigger texture. Then, when you need to use a tile, you bind the big texture it's stored in, and adjust the texture matrix so that [0,1] is mapped to the portion of the big texture that holds the tile you want. Voila - fewer textures!

There's really nothing you can do with individual textures that you can't do with this method, except borders and wrapping coords.

delphiripper
12-02-2004, 01:04 PM
Ahhhhh I see :)

Now I get it. That'll work. Thanks for the tip :)