From cb7af3f4cac90f95926477b4001f9f80037568d5 Mon Sep 17 00:00:00 2001 From: Jun Zhang Date: Sun, 30 Jan 2022 12:30:02 +0800 Subject: refactor: adjust the project infra. (#1) * refactor: adjust the project infra. This patch adds cmake build system to the project, and adjust infrastructure stuff. Signed-off-by: Jun Zhang * fix: remove compiler flags that only exist in GCC. Signed-off-by: Jun Zhang --- src/window.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/window.h (limited to 'src/window.h') diff --git a/src/window.h b/src/window.h new file mode 100644 index 0000000..bdd1e91 --- /dev/null +++ b/src/window.h @@ -0,0 +1,36 @@ +#pragma once + +#include + +class Bitmap; + +struct SDL_Window; +struct SDL_Renderer; +struct SDL_Texture; + +class Window { +public: + Window(const char* title, int width, int height, int scale); + ~Window(); + + void update(); + void draw(Bitmap&); + + bool shouldClose() { return !m_isRunning; } + + void onMouseDown(std::function callback) { m_mouseDown = callback; } + void onMouseUp(std::function callback) { m_mouseUp = callback; } + void onMouseMove(std::function callback) { m_mouseMove = callback; } +private: + bool m_isRunning; + + int m_width, m_height, m_scale; + + SDL_Window* m_window; + SDL_Renderer* m_renderer; + SDL_Texture* m_texture; + + std::function m_mouseDown; + std::function m_mouseUp; + std::function m_mouseMove; +}; \ No newline at end of file -- cgit v1.2.3