add sdl_deleter.h for RAII SDL resources

This commit is contained in:
scawful
2024-08-07 09:59:08 -04:00
parent 1d4b86d61c
commit 1f9f09ce79
2 changed files with 29 additions and 18 deletions

View File

@@ -0,0 +1,26 @@
#ifndef YAZE_APP_CORE_UTILS_SDL_DELETER_H_
#define YAZE_APP_CORE_UTILS_SDL_DELETER_H_
namespace yaze {
namespace app {
namespace core {
struct sdl_deleter {
void operator()(SDL_Window *p) const {
if (p) {
SDL_DestroyWindow(p);
}
}
void operator()(SDL_Renderer *p) const {
if (p) {
SDL_DestroyRenderer(p);
}
}
void operator()(SDL_Texture *p) const { SDL_DestroyTexture(p); }
};
} // namespace core
} // namespace app
} // namespace yaze
#endif // YAZE_APP_CORE_UTILS_SDL_DELETER_H_