1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 01:59:43 +01:00

Add Screen::destroy()

In order to have squeaky-clean memory management, we'll need to clean up
all the things that Screen allocates. This is the function to call to do
so.
This commit is contained in:
Misa 2021-02-15 17:47:11 -08:00 committed by Ethan Lee
parent 7f3ebda8ea
commit a3ad7b73f3
2 changed files with 16 additions and 0 deletions

View file

@ -93,6 +93,21 @@ void Screen::init(const ScreenSettings& settings)
ResizeScreen(settings.windowWidth, settings.windowHeight);
}
void Screen::destroy()
{
#define X(CLEANUP, POINTER) \
CLEANUP(POINTER); \
POINTER = NULL;
/* Order matters! */
X(SDL_DestroyTexture, m_screenTexture);
X(SDL_FreeSurface, m_screen);
X(SDL_DestroyRenderer, m_renderer);
X(SDL_DestroyWindow, m_window);
#undef X
}
void Screen::GetSettings(ScreenSettings* settings)
{
int width, height;

View file

@ -9,6 +9,7 @@ class Screen
{
public:
void init(const ScreenSettings& settings);
void destroy();
void GetSettings(ScreenSettings* settings);