aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/facade/SDLContext.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/facade/SDLContext.h')
-rw-r--r--src/crepe/facade/SDLContext.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/crepe/facade/SDLContext.h b/src/crepe/facade/SDLContext.h
index 80b76dd..0a8dbcf 100644
--- a/src/crepe/facade/SDLContext.h
+++ b/src/crepe/facade/SDLContext.h
@@ -3,6 +3,7 @@
#include <SDL2/SDL_keycode.h>
#include <SDL2/SDL_render.h>
#include <SDL2/SDL_video.h>
+#include <memory>
#include <string>
#include "../api/Sprite.h"
@@ -130,11 +131,19 @@ private:
void camera(const Camera & camera);
private:
- //TODO: Make this RAII
- //! sdl window
- SDL_Window * game_window = nullptr;
+ struct WindowDeleter {
+ void operator()(SDL_Window * window) { SDL_DestroyWindow(window); }
+ };
+
+ struct RendererDeleter {
+ void operator()(SDL_Renderer * renderer) { SDL_DestroyRenderer(renderer); }
+ };
+
+ //! sdl Window
+ std::unique_ptr<SDL_Window, WindowDeleter> game_window;
+
//! renderer for the crepe engine
- SDL_Renderer * game_renderer = nullptr;
+ std::unique_ptr<SDL_Renderer, RendererDeleter> game_renderer;
//! viewport for the camera window
SDL_Rect viewport = {0, 0, 640, 480};