1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 10:09:43 +01: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);