From 81f662083f1f6a4082b907db70e8bb045edced79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Fri, 21 May 2021 12:07:52 +0200 Subject: [PATCH] fixing abstract Window.hpp --- lib/Ray/sources/Canvas.hpp | 2 +- lib/Ray/sources/Drawables/Texture.cpp | 6 ++++++ lib/Ray/sources/Drawables/Texture.hpp | 4 ++-- lib/Ray/sources/Window.hpp | 2 +- sources/main.cpp | 19 +++++++++++-------- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/lib/Ray/sources/Canvas.hpp b/lib/Ray/sources/Canvas.hpp index 8fba2b93..81af1418 100644 --- a/lib/Ray/sources/Canvas.hpp +++ b/lib/Ray/sources/Canvas.hpp @@ -18,7 +18,7 @@ namespace RAY { virtual ~Canvas() = default; //! @brief draw drawable - virtual void draw(const Drawables::IDrawable &) = 0; + virtual void draw(Drawables::IDrawable &) = 0; protected: private: diff --git a/lib/Ray/sources/Drawables/Texture.cpp b/lib/Ray/sources/Drawables/Texture.cpp index c108f51c..c70d9097 100644 --- a/lib/Ray/sources/Drawables/Texture.cpp +++ b/lib/Ray/sources/Drawables/Texture.cpp @@ -42,4 +42,10 @@ Image RAY::Texture::toImage(void) const const ::Texture &RAY::Texture::getTexture(void) const { return this->_texture; +} + +bool RAY::Texture::unload() +{ + UnloadTexture(this->_texture); + return true; } \ No newline at end of file diff --git a/lib/Ray/sources/Drawables/Texture.hpp b/lib/Ray/sources/Drawables/Texture.hpp index 73d940cc..99c38eef 100644 --- a/lib/Ray/sources/Drawables/Texture.hpp +++ b/lib/Ray/sources/Drawables/Texture.hpp @@ -35,14 +35,14 @@ namespace RAY Texture &operator=(const Texture &) = default; //! @brief Texture destructor, will unload ressources - ~Texture(); + ~Texture() override; //! @brief load ressources from file //! @param filename: path of input bool load(const std::string &filename); //! @brief unload ressources - bool unload(); + bool unload() override; //! @brief get image ::Image toImage(void) const; diff --git a/lib/Ray/sources/Window.hpp b/lib/Ray/sources/Window.hpp index 04874cc8..d69795bb 100644 --- a/lib/Ray/sources/Window.hpp +++ b/lib/Ray/sources/Window.hpp @@ -96,7 +96,7 @@ namespace RAY { //! @brief draw rectangle //! @param drawable The drawable to render on screen - void draw(Drawables::IDrawable &drawable); + void draw(Drawables::IDrawable &drawable) override; //! @brief draw texture at position //! @param texture The object to render diff --git a/sources/main.cpp b/sources/main.cpp index 274ba73f..c7577e6a 100644 --- a/sources/main.cpp +++ b/sources/main.cpp @@ -9,13 +9,16 @@ int main() const int screenWidth = 800; const int screenHeight = 450; - InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window"); + RAY::Window w(screenWidth, screenHeight, "Arthur it works", true); - SetTargetFPS(60); // Set our game to run at 60 frames-per-second +// InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window"); + + w.setFPS(60); + //SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key + while (!w.shouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- @@ -24,19 +27,19 @@ int main() // Draw //---------------------------------------------------------------------------------- - BeginDrawing(); + w.beginDrawing(); - ClearBackground(RAYWHITE); + w.clear(RAYWHITE); - DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY); + DrawText("Congrats! You created your first window !", 190, 200, 20, LIGHTGRAY); - EndDrawing(); + w.endDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context + w.close(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0;