From 29627a93c68b9f3927ee9d1097ed3266777b6a0b Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 7 Nov 2021 06:33:07 +0100 Subject: Fix exit being called when closing window, respond to wm ping, add is_open function to window --- include/mglpp/graphics/Image.hpp | 1 + include/mglpp/graphics/Shader.hpp | 1 + include/mglpp/graphics/Text.hpp | 2 +- include/mglpp/system/FloatRect.hpp | 6 +++--- include/mglpp/system/vec.hpp | 3 ++- include/mglpp/window/Event.hpp | 9 ++++++++- 6 files changed, 16 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/mglpp/graphics/Image.hpp b/include/mglpp/graphics/Image.hpp index 1ddeb88..a868ad6 100644 --- a/include/mglpp/graphics/Image.hpp +++ b/include/mglpp/graphics/Image.hpp @@ -19,6 +19,7 @@ namespace mgl { unsigned char* data(); size_t get_byte_size(); vec2i get_size() const; + int get_num_channels() const; mgl_image* internal_image(); private: diff --git a/include/mglpp/graphics/Shader.hpp b/include/mglpp/graphics/Shader.hpp index 47e9689..0aedc47 100644 --- a/include/mglpp/graphics/Shader.hpp +++ b/include/mglpp/graphics/Shader.hpp @@ -20,6 +20,7 @@ namespace mgl { ~Shader(); bool load_from_file(const char *filepath, Type type); + bool set_uniform(const char *name, float value); bool set_uniform(const char *name, vec2f value); bool is_valid() const; diff --git a/include/mglpp/graphics/Text.hpp b/include/mglpp/graphics/Text.hpp index 23f847c..6166087 100644 --- a/include/mglpp/graphics/Text.hpp +++ b/include/mglpp/graphics/Text.hpp @@ -23,7 +23,7 @@ namespace mgl { void set_color(Color color) override; vec2f get_position() const override; - FloatRect get_local_bounds(); + FloatRect get_bounds() const; void set_string(std::string str); const std::string& get_string() const; diff --git a/include/mglpp/system/FloatRect.hpp b/include/mglpp/system/FloatRect.hpp index e187b50..50941dd 100644 --- a/include/mglpp/system/FloatRect.hpp +++ b/include/mglpp/system/FloatRect.hpp @@ -7,10 +7,10 @@ namespace mgl { template class Rect { public: - Rect() : position(0.0f, 0.0f), size(0.0f, 0.0f) {} - Rect(const vec2& position, const vec2& size) : position(position), size(size) {} + Rect() : position(0, 0), size(0, 0) {} + Rect(vec2 position, vec2 size) : position(position), size(size) {} - bool contains(const vec2& point) const { + bool contains(vec2 point) const { return point.x >= position.x && point.x <= position.x + size.x && point.y >= position.y && point.y <= position.y + size.y; } diff --git a/include/mglpp/system/vec.hpp b/include/mglpp/system/vec.hpp index ea6eba5..c81cdfa 100644 --- a/include/mglpp/system/vec.hpp +++ b/include/mglpp/system/vec.hpp @@ -4,7 +4,8 @@ namespace mgl { template struct vec2 { - vec2(T x = 0, T y = 0) : x(x), y(y) {} + vec2() : x(0), y(0) {} + vec2(T x, T y) : x(x), y(y) {} vec2 operator + (vec2 other) const { return { x + other.x, y + other.y }; diff --git a/include/mglpp/window/Event.hpp b/include/mglpp/window/Event.hpp index c073251..5b7da45 100644 --- a/include/mglpp/window/Event.hpp +++ b/include/mglpp/window/Event.hpp @@ -15,6 +15,10 @@ namespace mgl { int height; }; + struct TextEvent { + uint32_t codepoint; + }; + struct KeyEvent { Keyboard::Key code; bool alt; @@ -36,7 +40,9 @@ namespace mgl { enum Type : int { Unknown, - Resized, + Closed, /* Window closed */ + Resized, /* Window resized */ + TextEntered, KeyPressed, KeyReleased, MouseButtonPressed, @@ -48,6 +54,7 @@ namespace mgl { union { SizeEvent size; + TextEvent text; KeyEvent key; MouseButtonEvent mouse_button; MouseMoveEvent mouse_move; -- cgit v1.2.3