Go to the documentation of this file.
5 #ifndef COMSQUARE_SFRENDERER_HPP
6 #define COMSQUARE_SFRENDERER_HPP
9 #include <SFML/Graphics.hpp>
10 #include <SFML/Audio.hpp>
11 #include <SFML/System.hpp>
12 #include <SFML/Window.hpp>
13 #include <SFML/Graphics/RenderWindow.hpp>
22 :
_msg(
"Trying to place a pixel at an invalid " + name +
" (" + std::to_string(x) +
">=" + std::to_string(width) +
")") {}
23 const char *
what() const noexcept
override {
return this->_msg.c_str(); }
55 void putPixel(
unsigned y,
unsigned x, uint32_t rgba)
override;
59 void playAudio(std::span<int16_t> samples)
override;
69 SFRenderer(
unsigned int height,
unsigned int width);
76 #endif //COMSQUARE_SFRENDERER_HPP
std::string _msg
Definition: SFRenderer.hpp:19
void drawScreen() override
Update the screen by printing the buffer.
Definition: SFRenderer.cpp:48
void setWindowName(std::string &newWindowName) override
Set a new name to the window, if there is already a name it will be overwrite.
Definition: SFRenderer.cpp:43
Definition: IRenderer.hpp:13
sf::VideoMode _videoMode
Video Mode containing the _height and _width of the window.
Definition: SFRenderer.hpp:31
const char * what() const noexcept override
Definition: SFRenderer.hpp:23
Definition: SFRenderer.hpp:17
~SFRenderer()
Definition: SFRenderer.cpp:38
void playAudio(std::span< int16_t > samples) override
Playing all samples from buffer.
Definition: SFRenderer.cpp:56
void getEvents()
Get the inputs from the Window.
Definition: SFRenderer.cpp:72
sf::Texture _texture
The texture to render the array of pixels.
Definition: SFRenderer.hpp:37
Definition: SFRenderer.hpp:26
Container of all the components of the SNES.
Definition: SNES.hpp:32
sf::SoundBuffer _soundBuffer
The buffer containing samples to be played.
Definition: SFRenderer.hpp:40
InvalidPixelPosition(const std::string &name, unsigned int x, unsigned int width)
Definition: SFRenderer.hpp:21
sf::Sound _sound
the sound played
Definition: SFRenderer.hpp:42
void putPixel(unsigned y, unsigned x, uint32_t rgba) override
Add a pixel to the buffer to the coordinates x, y with the color rgba.
Definition: SFRenderer.cpp:62
SFRenderer & operator=(const SFRenderer &)=delete
Definition: IRenderer.hpp:15
sf::Sprite _sprite
The sprite to render the array of pixels.
Definition: SFRenderer.hpp:35
void createWindow(SNES &snes, int maxFPS) override
Use this function to create the window.
Definition: SFRenderer.cpp:23
sf::Color * _pixelBuffer
The image that contain all of the pixels.
Definition: SFRenderer.hpp:33
sf::RenderWindow _window
The Renderer for the window.
Definition: SFRenderer.hpp:29
bool shouldExit
Tells to the program if the window has been closed, and therefore if he should stop.
Definition: SFRenderer.hpp:45
SFRenderer(unsigned int height, unsigned int width)
Constructor that return the window component of the SFML.
Definition: SFRenderer.cpp:14