1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-25 22:18:30 +02:00

Add Graphics::destroy_buffers()

These destroy all the buffers that are created on the Graphics class.
Since these buffers can't be created at the same time as the rest of
Graphics is (due to the fact that they require knowing the pixel format
of the game screen), they can't be destroyed at the same as the rest of
Graphics is, either.
This commit is contained in:
Misa 2021-02-15 16:16:52 -08:00 committed by Ethan Lee
parent 3fe1870b32
commit 5595bb0964
2 changed files with 24 additions and 0 deletions

View File

@ -170,6 +170,28 @@ void Graphics::destroy()
#undef CLEAR_ARRAY
}
void Graphics::destroy_buffers()
{
#define FREE_SURFACE(SURFACE) \
SDL_FreeSurface(SURFACE); \
SURFACE = NULL;
FREE_SURFACE(backBuffer)
FREE_SURFACE(footerbuffer)
FREE_SURFACE(ghostbuffer)
FREE_SURFACE(foregroundBuffer)
FREE_SURFACE(menubuffer)
FREE_SURFACE(warpbuffer)
FREE_SURFACE(warpbuffer_lerp)
FREE_SURFACE(towerbg.buffer)
FREE_SURFACE(towerbg.buffer_lerp)
FREE_SURFACE(titlebg.buffer)
FREE_SURFACE(titlebg.buffer_lerp)
FREE_SURFACE(tempBuffer)
#undef FREE_SURFACE
}
int Graphics::font_idx(uint32_t ch) {
if (font_positions.size() > 0) {
std::map<int, int>::iterator iter = font_positions.find(ch);

View File

@ -19,6 +19,8 @@ public:
void init();
void destroy();
void destroy_buffers();
GraphicsResources grphx;
int bfontlen(uint32_t ch);