diff --git a/main.cpp b/main.cpp index 75f71c3..b72a31d 100644 --- a/main.cpp +++ b/main.cpp @@ -21,6 +21,10 @@ int main(int argc, char **argv) bus.mapComponents(snes); Renderer::SFRenderer renderer(600, 800, 60); + renderer.setWindowName("Fire Emblem : Three Houses"); + while (!renderer.shouldExit) { + renderer.getEvents(); + } return 0; } \ No newline at end of file diff --git a/sources/Renderer/IRenderer.hpp b/sources/Renderer/IRenderer.hpp index a33f515..2ac7c37 100644 --- a/sources/Renderer/IRenderer.hpp +++ b/sources/Renderer/IRenderer.hpp @@ -14,7 +14,7 @@ namespace ComSquare::Renderer //! @brief Set a new name to the window, if there is already a name it will be overwrite virtual void setWindowName(std::string) = 0; //! @brief Tells to the program if the window has been closed, and therefore if he should stop - bool shouldExit; + bool shouldExit = true; //! @brief Render the buffer to the window virtual void drawScreen() = 0; //! @brief Set a pixel to the coordinates x, y with the color rgba diff --git a/sources/Renderer/SFRenderer.cpp b/sources/Renderer/SFRenderer.cpp index cbd5c1f..62057c3 100644 --- a/sources/Renderer/SFRenderer.cpp +++ b/sources/Renderer/SFRenderer.cpp @@ -8,12 +8,13 @@ #include #include #include +#include namespace ComSquare::Renderer { void SFRenderer::setWindowName(std::string newWindowName) { - this->window.setTitle(newWindowName); + this->window.setTitle(newWindowName + " - ComSquare"); } void SFRenderer::drawScreen() @@ -40,4 +41,15 @@ namespace ComSquare::Renderer this->texture.create(width, height); } + void SFRenderer::getEvents() + { + sf::Event event; + while (this->window.pollEvent(event)) { + if (event.type == sf::Event::Closed) { + this->shouldExit = true; + break; + } + } + } + } diff --git a/sources/Renderer/SFRenderer.hpp b/sources/Renderer/SFRenderer.hpp index c248ad7..e643847 100644 --- a/sources/Renderer/SFRenderer.hpp +++ b/sources/Renderer/SFRenderer.hpp @@ -39,6 +39,8 @@ namespace ComSquare::Renderer //! @param Y vertical index. //! @param rgba The color of the pixel. void putPixel(int x, int y, uint8_t rgba) override ; + //! @brief Get the inputs from the Window + void getEvents(); //! @brief Constructor that return the window component of the SFML. //! @param height height of the window. //! @param width width of the window.