Sign in to follow this  

Texture with many tiles.

This topic is 4867 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I'm currently working on a tile-based game in OpenGL/C++/win32.. But now I have a problem.. It seems that I cannot use textures larger than 512*512 or 1024*1024, otherwise I would lose compatibility with some video cards.. And, since my tiles are 64*64 pixels, I can only have 256 tiles on a 1024*1024 texture. I need more than 256 different tiles sometimes, so I don't know what would be the best thing to do. I don't want to use many different textures, otherwise I would waste time binding to other textures in my rendering loop. Any suggestion on what could I do to have access to more tiles?

Share this post


Link to post
Share on other sites
you could make the tiles smaller and have them stretched (but then it'd not look as nice of course).

you could use multiple textures, and batch your drawing of tiles so there are only as many texture switches as there are textures (i.e. draw all tiles using texture1, then switch, then draw all tiles using texture2, etc etc).

or, you could just say "screw those people with old video cards", but i get the impression you don't want to do that :)

Share this post


Link to post
Share on other sites
I think this idea of textures switching might be good.. Thought I see a problem with that.. The only way I see to actually store the data for this system would be to have as much layers as there are textures, and draw the layers one after one with the different texture..
But then, on each layer, there would be many empty tiles, since the correct tiles we want to be drawn would be distributed among the different layers. And that would mean some memory/cpu waste..
Do you see any more efficient way to achieve your idea?

Share this post


Link to post
Share on other sites
I'm not sure how you mean.

For me, each tile has a pointer to the texture [actually a stack of textures] it is rendered with. The actual textures are held in a texture manager so they only exist once in memory.

This is perhaps a simplistic description, but good enough?

So yes, that means I will swap textures, and make a draw primitive call per layer, per tile and that each static image gets its own texture [though mine are 256x256]. Horribly inefficient, but it's not as though I'm going to tax semi-modern video cards with a few hundred static sprites.

On my machine I've gotten my engine up slightly over 10000 dynamic sprites [which my tiles are not] before noticing slowdown.

Share this post


Link to post
Share on other sites

This topic is 4867 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this