aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/mglpp/graphics/Color.hpp11
-rw-r--r--include/mglpp/graphics/Drawable.hpp3
-rw-r--r--include/mglpp/graphics/Font.hpp3
-rw-r--r--include/mglpp/graphics/Image.hpp27
-rw-r--r--include/mglpp/graphics/Rectangle.hpp2
-rw-r--r--include/mglpp/graphics/Sprite.hpp7
-rw-r--r--include/mglpp/graphics/Text.hpp1
-rw-r--r--include/mglpp/system/vec.hpp12
-rw-r--r--include/mglpp/window/Event.hpp11
-rw-r--r--include/mglpp/window/Window.hpp14
10 files changed, 81 insertions, 10 deletions
diff --git a/include/mglpp/graphics/Color.hpp b/include/mglpp/graphics/Color.hpp
index 0d0ac15..1cade84 100644
--- a/include/mglpp/graphics/Color.hpp
+++ b/include/mglpp/graphics/Color.hpp
@@ -9,6 +9,17 @@ namespace mgl {
}
+ bool operator == (const Color &other) const {
+ return r == other.r
+ && g == other.g
+ && b == other.b
+ && a == other.a;
+ }
+
+ bool operator != (const Color &other) const {
+ return !(operator==(other));
+ }
+
uint8_t r, g, b, a;
};
}
diff --git a/include/mglpp/graphics/Drawable.hpp b/include/mglpp/graphics/Drawable.hpp
index 3aa8d4f..f4766fb 100644
--- a/include/mglpp/graphics/Drawable.hpp
+++ b/include/mglpp/graphics/Drawable.hpp
@@ -10,8 +10,11 @@ namespace mgl {
friend class Window;
public:
virtual ~Drawable() = default;
+
virtual void set_position(vec2f position) = 0;
virtual void set_color(Color color) = 0;
+
+ virtual vec2f get_position() const = 0;
protected:
virtual void draw(Window &window) = 0;
};
diff --git a/include/mglpp/graphics/Font.hpp b/include/mglpp/graphics/Font.hpp
index 1faa23a..6818277 100644
--- a/include/mglpp/graphics/Font.hpp
+++ b/include/mglpp/graphics/Font.hpp
@@ -11,7 +11,8 @@ namespace mgl {
Font();
~Font();
- bool load_from_file(const char *filepath, unsigned int font_size);
+ bool load_from_file(const char *filepath, unsigned int character_size);
+ unsigned int get_character_size() const;
mgl_font* internal_font();
private:
diff --git a/include/mglpp/graphics/Image.hpp b/include/mglpp/graphics/Image.hpp
new file mode 100644
index 0000000..d8df2c3
--- /dev/null
+++ b/include/mglpp/graphics/Image.hpp
@@ -0,0 +1,27 @@
+#ifndef MGLPP_IMAGE_HPP
+#define MGLPP_IMAGE_HPP
+
+#include "../system/vec.hpp"
+
+extern "C" {
+#include <mgl/graphics/image.h>
+}
+
+namespace mgl {
+ class Image {
+ public:
+ Image();
+ ~Image();
+
+ bool load_from_file(const char *filepath);
+ unsigned char* data();
+ size_t byte_size();
+ vec2i size() const;
+
+ mgl_image* internal_image();
+ private:
+ mgl_image image;
+ };
+}
+
+#endif /* MGLPP_IMAGE_HPP */
diff --git a/include/mglpp/graphics/Rectangle.hpp b/include/mglpp/graphics/Rectangle.hpp
index 7bc9373..44a5f36 100644
--- a/include/mglpp/graphics/Rectangle.hpp
+++ b/include/mglpp/graphics/Rectangle.hpp
@@ -14,6 +14,8 @@ namespace mgl {
void set_position(vec2f position) override;
void set_color(Color color) override;
+ vec2f get_position() const override;
+ void set_size(vec2f size);
protected:
void draw(Window &window) override;
private:
diff --git a/include/mglpp/graphics/Sprite.hpp b/include/mglpp/graphics/Sprite.hpp
index 8a03de5..d3b8885 100644
--- a/include/mglpp/graphics/Sprite.hpp
+++ b/include/mglpp/graphics/Sprite.hpp
@@ -16,6 +16,13 @@ namespace mgl {
void set_position(vec2f position) override;
void set_color(Color color) override;
+ vec2f get_position() const override;
+ void set_scale(vec2f scale);
+ void set_scale(float scale);
+
+ vec2f get_scale() const;
+
+ const Texture& get_texture() const;
protected:
void draw(Window &window) override;
private:
diff --git a/include/mglpp/graphics/Text.hpp b/include/mglpp/graphics/Text.hpp
index d126994..fc02244 100644
--- a/include/mglpp/graphics/Text.hpp
+++ b/include/mglpp/graphics/Text.hpp
@@ -16,6 +16,7 @@ namespace mgl {
void set_position(vec2f position) override;
void set_color(Color color) override;
+ vec2f get_position() const override;
protected:
void draw(Window &window) override;
private:
diff --git a/include/mglpp/system/vec.hpp b/include/mglpp/system/vec.hpp
index 40262f0..ac06a52 100644
--- a/include/mglpp/system/vec.hpp
+++ b/include/mglpp/system/vec.hpp
@@ -3,17 +3,21 @@
namespace mgl {
struct vec2f {
- float x = 0.0f;
- float y = 0.0f;
+ vec2f(float x = 0.0f, float y = 0.0f) : x(x), y(y) {}
+
+ float x;
+ float y;
};
struct vec2i {
- int x = 0;
- int y = 0;
+ vec2i(int x = 0, int y = 0) : x(x), y(y) {}
vec2f to_vec2f() const {
return { (float)x, (float)y };
}
+
+ int x;
+ int y;
};
}
diff --git a/include/mglpp/window/Event.hpp b/include/mglpp/window/Event.hpp
new file mode 100644
index 0000000..ecfb380
--- /dev/null
+++ b/include/mglpp/window/Event.hpp
@@ -0,0 +1,11 @@
+#ifndef MGLPP_EVENT_HPP
+#define MGLPP_EVENT_HPP
+
+namespace mgl {
+ class Event {
+ public:
+
+ };
+}
+
+#endif /* MGLPP_EVENT_HPP */
diff --git a/include/mglpp/window/Window.hpp b/include/mglpp/window/Window.hpp
index 79e999d..916e891 100644
--- a/include/mglpp/window/Window.hpp
+++ b/include/mglpp/window/Window.hpp
@@ -1,6 +1,7 @@
#ifndef MGLPP_WINDOW_HPP
#define MGLPP_WINDOW_HPP
+#include "../graphics/Color.hpp"
#include "../system/vec.hpp"
extern "C" {
@@ -8,7 +9,11 @@ extern "C" {
}
namespace mgl {
+ typedef mgl_window_handle WindowHandle;
+
+ class Event;
class Drawable;
+
class Window {
public:
class Delegate {
@@ -17,19 +22,18 @@ namespace mgl {
virtual void draw() = 0;
};
- Window(Delegate *delegate);
+ Window();
~Window();
bool create(const char *title, int width, int height);
- void poll_events();
- void draw();
+ bool poll_event(Event &event);
+ void clear(mgl::Color color = mgl::Color(0, 0, 0, 255));
void draw(Drawable &drawable);
+ void display();
vec2i get_cursor_position() const;
- Delegate* get_delegate();
private:
mgl_window window;
- Delegate *delegate;
};
}