1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-26 06:28:30 +02: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);