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:
parent
7f3ebda8ea
commit
a3ad7b73f3
2 changed files with 16 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -9,6 +9,7 @@ class Screen
|
|||
{
|
||||
public:
|
||||
void init(const ScreenSettings& settings);
|
||||
void destroy();
|
||||
|
||||
void GetSettings(ScreenSettings* settings);
|
||||
|
||||
|
|
Loading…
Reference in a new issue