SDL - Destroying SDL_Textures*

Hello,

So I have a SDL_Texture* wrapper called CTexture that just has a private member of SDL_Texture* which stores an image of the texture in question. I want to create a button that is a CTexture, but when the button is clicked, I want it to be "destroyed" (invisible - not interfering with anything else).

I have a function now (Destination is an SDL_Rect for destination rendering):

1
2
3
4
5
6
7
8
9
void CTexture::destroy()
{
	SDL_DestroyTexture(texture);
	texture = nullptr;
	destination.h = 0;
	destination.w = 0;
	destination.x = -1;
	destination.y = -1;
}


Is it valid to destroy a texture while a program is running and set it to null? It won't break anything? Am I doing it wrong?


If you need more of my code, let me know.

Yes, it's valid as long as you don't reference your texture again.
Topic archived. No new replies allowed.