diff options
author | Jun Zhang <jun@junz.org> | 2022-01-30 12:30:02 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-29 21:30:02 -0700 |
commit | cb7af3f4cac90f95926477b4001f9f80037568d5 (patch) | |
tree | 022f4700c796a9935acd3ee0d0fd80a812a78464 /src/window.h | |
parent | 99b4763f1028e72bb06d8db6c7e8ace469f8989c (diff) |
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 <jun@junz.org>
* fix: remove compiler flags that only exist in GCC.
Signed-off-by: Jun Zhang <jun@junz.org>
Diffstat (limited to 'src/window.h')
-rw-r--r-- | src/window.h | 36 |
1 files changed, 36 insertions, 0 deletions
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 <functional> + +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<void(int, int, int)> callback) { m_mouseDown = callback; } + void onMouseUp(std::function<void(int, int, int)> callback) { m_mouseUp = callback; } + void onMouseMove(std::function<void(int, int)> 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<void(int, int, int)> m_mouseDown; + std::function<void(int, int, int)> m_mouseUp; + std::function<void(int, int)> m_mouseMove; +};
\ No newline at end of file |