SDL Handling Sprites, resource and memory

Started by
0 comments, last by vstrakh 7 years, 4 months ago

Hi all,

im having trouble with handling resources, i only have 69 sprite sheets for animations but i am getting "not enough memory" when converting a surface to texture during sprite loading. Im using PNG for my sprites along with the backgrounds and other stuff.

What advise can you guys give in handling this? will it make a difference if i use a different file format instead, like let's say a TGA instead of PNG?

i dont want to render and handle the sprites from CPU, as it will slow down the process like converting from surface to texture every frame or if needed.

what else can i do to handle this issue?

Advertisement

1. What's the sizes of those spritesheets?

2. What's packed in single spritesheet?

3. Are they all visible on screen at the same time?

4. Any chances that you're leaking resources, by loading it periodically but not freeing?

will it make a difference if i use a different file format instead, like let's say a TGA instead of PNG?

That's external files format. Internally these formats will be unpacked into raw array of pixels, so there's no difference if you're using tga or png.

what else can i do to handle this issue?

Avoid loading data that won't be visible.

If spritesheet has animations for multiple characters - split it. Let every character have own spritesheet, so it can be loaded only if that character appears on screen, and unloaded when character goes out.

If your graphics allows it (in terms of visual quality), try to use compressed textures (DDS file with DXT1 compression and 1-bit alpha).

Otherwise consider reducing sprite sizes/resolution.

This topic is closed to new replies.

Advertisement