SFML community forums

Help => Graphics => Topic started by: slotdev on July 19, 2012, 04:19:02 pm

Title: Deallocating sprites/textures
Post by: slotdev on July 19, 2012, 04:19:02 pm
Hi

Quick question...I have a texture and sprite which I load from file and then draw, on start-up (like a splash screen). When these have been displayed, I can then safely remove the texture and sprite as it is never needed again.

My texture & sprite are part of my "graphics engine" and so exist until the class is destroyed at program exit. But I need the video memory that the texture will use....so how do I deallocate it when I've drawn it?

I can move the sf::Texture to be local to my "loading" function...but on exit of this, will the VRAM be released?

Thanks
Ed
Title: Re: Deallocating sprites/textures
Post by: Laurent on July 19, 2012, 04:36:47 pm
The video memory is released when the sf::Texture instance is destroyed, of course. It would be very annoying for the developer, if it was not the case ;)
Title: Re: Deallocating sprites/textures
Post by: slotdev on July 19, 2012, 05:27:34 pm
I thought so, yes it would be a nightmare if it wasn't release :D

So move the sf::Texture to be local, and then it will be destroyed when the function ends. Great :)