0
\$\begingroup\$

I started a small project which is basically an isometric map with tiles. Right now I render only the visible tiles - at each rendering cycle.

Because I don't have experience with actual SDL2 projects I'm asking myself if I can store a large map (e.g. 10000 x 10000 tiles with 32px each) completely into an SDL_Texture. In my rendering routine I could slice out everything that's visible and draw a few things on top of it, e.g. units.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

I'd recommend against storing a huge image as a texture like that. SDL_Texture is stored in your video memory which only has so much space, usually a lot less than the main memory on your machine. Even if you're only drawing a screen sized portion of the texture you sill have 10000x * 10000y * 32px * 32bpp (almost 12Gb (I don't think they even sell cards with that much memory)) clogging up your vram.

You'll want to stick with tiles is what I'm saying. Best approach is to put all your tiles on the one image and load that up as a texture and then draw each of the visible tiles each draw. That way you pack a much smaller texture into vram. Don't worry too much about asking your gpu to draw a lot of sprites per frame if they're made in succession on the one texture, gpus are designed to do just that!

\$\endgroup\$
1
  • \$\begingroup\$ Thanks! Unfortunately I never had the memory in my mind only the performance aspect. \$\endgroup\$
    – tur1ng
    Jun 1, 2015 at 5:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .