1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-24 13:38:29 +02:00
VVVVVV/desktop_version/src/GraphicsUtil.h
Misa ea1a014145 Fix memory leak with ApplyFilter
The intention of the recent refactor was to make it so that the
temporary surfaces would be allocated only once, when the mode is
enabled, and be freed upon exit.

To do this, Graphics.cpp owns the pointers, and passes them to
ApplyFilter to modify. Except ApplyFilter doesn't actually modify the
pointers, because it's only a single pointer, not a pointer-to-pointer.
So every frame of rendering it would actually be creating a new surface
and leaking memory.

To fix this, they need to be pointer-to-pointer variables that get
modified.

I also added error logs in case the surface creation failed.
2023-10-27 10:25:42 -07:00

18 lines
461 B
C

#ifndef GRAPHICSUTIL_H
#define GRAPHICSUTIL_H
#include <SDL.h>
void setRect(SDL_Rect& _r, int x, int y, int w, int h);
SDL_Surface* GetSubSurface( SDL_Surface* metaSurface, int x, int y, int width, int height );
void DrawPixel(SDL_Surface* surface, int x, int y, SDL_Color color);
SDL_Color ReadPixel(const SDL_Surface* surface, int x, int y);
void UpdateFilter(void);
void ApplyFilter(SDL_Surface** src, SDL_Surface** dest);
#endif /* GRAPHICSUTIL_H */