Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Deallocating sprites/textures  (Read 2029 times)

0 Members and 1 Guest are viewing this topic.

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Deallocating sprites/textures
« 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
« Last Edit: July 19, 2012, 04:25:30 pm by slotdev »
SFML 2.1

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Deallocating sprites/textures
« Reply #1 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 ;)
Laurent Gomila - SFML developer

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Re: Deallocating sprites/textures
« Reply #2 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 :)
SFML 2.1

 

anything