diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-10-19 22:22:07 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-10-19 22:22:07 +0200 |
commit | fe1588ef18163c7557d3d0a62c085f42f2abfab2 (patch) | |
tree | d73f54a47ebfe6b2d289ed42c9a738a94e6095d1 /tests | |
parent | 6a524b46cb9c74c8d1b710c23bbc62bdafd54bb2 (diff) |
Change event layout to similar to same as sfml
Diffstat (limited to 'tests')
-rw-r--r-- | tests/main.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/tests/main.cpp b/tests/main.cpp index 3595717..3f149a3 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -1,16 +1,17 @@ #include <stdio.h> #include <mglpp/mglpp.hpp> #include <mglpp/window/Window.hpp> +#include <mglpp/window/Event.hpp> #include <mglpp/graphics/Texture.hpp> #include <mglpp/graphics/Sprite.hpp> #include <mglpp/graphics/Font.hpp> #include <mglpp/graphics/Text.hpp> #include <mglpp/graphics/Rectangle.hpp> -struct Delegate : public mgl::Window::Delegate { +struct Delegate { Delegate() {} - void draw() override { + void draw() { mgl::Rectangle rect(window->get_cursor_position().to_vec2f(), { 100.0f, 500.0f }); rect.set_color({255, 0, 0, 255}); window->draw(rect); @@ -31,8 +32,7 @@ struct Delegate : public mgl::Window::Delegate { int main(int argc, char **argv) { mgl::Init init; - Delegate delegate; - mgl::Window window(&delegate); + mgl::Window window; if(!window.create("mglpp", 1920, 1080)) return 1; @@ -44,13 +44,20 @@ int main(int argc, char **argv) { if(!font.load_from_file("/usr/share/fonts/noto/NotoSans-Regular.ttf", 32)) return 1; + Delegate delegate; delegate.window = &window; delegate.texture = &texture; delegate.font = &font; + mgl::Event event; while(true) { - window.poll_events(); - window.draw(); + if(window.poll_event(event)) { + + } + + window.clear(mgl::Color(0, 0, 0, 255)); + delegate.draw(); + window.display(); } return 0; |