diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-10-19 07:05:31 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-10-19 07:05:31 +0200 |
commit | 6a524b46cb9c74c8d1b710c23bbc62bdafd54bb2 (patch) | |
tree | 1dd13bd15b7f2c6de94a318e2d537f6bb7378dff | |
parent | 3e081d1669622bbc276b038ddc38ecf0600683c3 (diff) |
Use uint8_t for color instead of float
m--------- | depends/mgl | 0 | ||||
-rw-r--r-- | include/mglpp/graphics/Color.hpp | 11 | ||||
-rw-r--r-- | src/graphics/Rectangle.cpp | 2 | ||||
-rw-r--r-- | tests/main.cpp | 4 |
4 files changed, 10 insertions, 7 deletions
diff --git a/depends/mgl b/depends/mgl -Subproject 4a96d4a354fbde7fd614075c060aea78a3411b4 +Subproject 3bdf82eec2c915e91ae487e29d72639f9efcad6 diff --git a/include/mglpp/graphics/Color.hpp b/include/mglpp/graphics/Color.hpp index d1c1745..0d0ac15 100644 --- a/include/mglpp/graphics/Color.hpp +++ b/include/mglpp/graphics/Color.hpp @@ -1,12 +1,15 @@ #ifndef MGLPP_COLOR_HPP #define MGLPP_COLOR_HPP +#include <stdint.h> + namespace mgl { struct Color { - float r = 1.0f; - float g = 1.0f; - float b = 1.0f; - float a = 1.0f; + Color(uint8_t r = 255, uint8_t g = 255, uint8_t b = 255, uint8_t a = 255) : r(r), g(g), b(b), a(a) { + + } + + uint8_t r, g, b, a; }; } diff --git a/src/graphics/Rectangle.cpp b/src/graphics/Rectangle.cpp index 61a45f4..17060c7 100644 --- a/src/graphics/Rectangle.cpp +++ b/src/graphics/Rectangle.cpp @@ -6,7 +6,7 @@ extern "C" { namespace mgl { Rectangle::Rectangle(vec2f position, vec2f size) { - rectangle.color = { 1.0f, 1.0f, 1.0f, 1.0f }; + rectangle.color = { 255, 255, 255, 255 }; rectangle.position = { position.x, position.y }; rectangle.size = { size.x, size.y }; } diff --git a/tests/main.cpp b/tests/main.cpp index bddfc3f..3595717 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -12,11 +12,11 @@ struct Delegate : public mgl::Window::Delegate { void draw() override { mgl::Rectangle rect(window->get_cursor_position().to_vec2f(), { 100.0f, 500.0f }); - rect.set_color({1.0f, 0.0f, 0.0f, 1.0f}); + rect.set_color({255, 0, 0, 255}); window->draw(rect); mgl::Sprite sprite(*texture, { 100.0f - 10.0f, 0.0f }); - sprite.set_color({1.0f, 1.0f, 1.0f, 0.5f}); + sprite.set_color({255, 255, 255, 128}); window->draw(sprite); mgl::Text text("hello world!\nGood bye world!", { 0.0f, 0.0f }, *font); |