mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-05-31 09:32:36 +00:00
SFML working nicely can open and close the window and set a title
This commit is contained in:
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -8,12 +8,13 @@
|
||||
#include <SFML/System.hpp>
|
||||
#include <SFML/Window.hpp>
|
||||
#include <SFML/Graphics//RenderWindow.hpp>
|
||||
#include <iostream>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user