summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2019-01-23 01:12:09 +0100
committerNao Pross <naopross@thearcway.org>2019-01-23 01:12:09 +0100
commit467a6990b0ee9ba568008697ba2f31b26951dbeb (patch)
tree298c21e7c9da10c74023d0479139f2fc995fd06b /include
parentRemove test makefile (diff)
downloadlibwsdl2-467a6990b0ee9ba568008697ba2f31b26951dbeb.tar.gz
libwsdl2-467a6990b0ee9ba568008697ba2f31b26951dbeb.zip
Separate renderer from window
Diffstat (limited to 'include')
-rw-r--r--include/video.hpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/include/video.hpp b/include/video.hpp
index a00f77e..23c1c6e 100644
--- a/include/video.hpp
+++ b/include/video.hpp
@@ -12,13 +12,37 @@ namespace wsdl2 {
typedef SDL_Point point;
typedef SDL_Rect rect;
+ class window;
+
+ class renderer {
+ public:
+ friend class window;
+
+ renderer(window& w);
+ virtual ~renderer();
+
+ inline void clear() { SDL_RenderClear(safe()); }
+ inline void present() { SDL_RenderPresent(safe()); }
+
+ // dirty C code
+ inline SDL_Renderer* sdl() { return m_renderer; }
+
+ private:
+ renderer();
+
+ SDL_Renderer* safe();
+ void create_sdl_renderer(SDL_Window *win);
+
+ SDL_Renderer *m_renderer;
+ };
+
class window {
public:
window() = delete;
window(const window& other) = delete;
window(const std::string& title, std::size_t width, std::size_t height);
- ~window();
+ virtual ~window();
// setters
void open();
@@ -35,9 +59,15 @@ namespace wsdl2 {
// rendering
void update();
+ // dirty C code
+ inline SDL_Window* sdl() { return m_window; }
+
private:
bool m_open;
+ renderer m_renderer;
SDL_Window *m_window;
- SDL_Renderer *m_renderer;
};
+
+
+
} \ No newline at end of file