Sign in to follow this  
cebugdev

SDL Handling Sprites, resource and memory

Recommended Posts

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?

 

 

Share this post


Link to post
Share on other sites

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.

Edited by vstrakh

Share this post


Link to post
Share on other sites

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