mirror of
https://github.com/zoriya/ComSquare.git
synced 2025-12-19 21:55:11 +00:00
SFRenderer and setWindowName added and a documentation fix
This commit is contained in:
@@ -3,17 +3,29 @@
|
||||
//
|
||||
|
||||
#include "SFRenderer.hpp"
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <SFML/Audio.hpp>
|
||||
#include <SFML/System.hpp>
|
||||
#include <SFML/Window.hpp>
|
||||
#include <SFML/Graphics//RenderWindow.hpp>
|
||||
|
||||
namespace ComSquare::Renderer
|
||||
{
|
||||
void SFRenderer::setWindowName(std::string)
|
||||
void SFRenderer::setWindowName(std::string newWindowName)
|
||||
{
|
||||
|
||||
this->window.setTitle(newWindowName);
|
||||
}
|
||||
|
||||
void SFRenderer::drawScreen()
|
||||
{
|
||||
sf::Sprite sprite;
|
||||
sf::Image image;
|
||||
image.loadFromMemory(this->pixelBuffer, sizeof(sf::Uint8 *) * this->videoMode.height * this->videoMode.width * 4);
|
||||
|
||||
//image.LoadFromPixels(800, 600, this->pixelBuffer);
|
||||
//sprite.SetImage(image);
|
||||
//window.Draw(sprite);
|
||||
//window.Display();
|
||||
}
|
||||
|
||||
void SFRenderer::putPixel(int x, int y, uint8_t rgba)
|
||||
@@ -22,4 +34,16 @@ namespace ComSquare::Renderer
|
||||
(void) y;
|
||||
(void) rgba;
|
||||
}
|
||||
|
||||
SFRenderer::SFRenderer(unsigned int height, unsigned int width, int maxFPS)
|
||||
{
|
||||
this->shouldExit = false;
|
||||
this->videoMode = {static_cast<unsigned int>(width), static_cast<unsigned int>(height), 32};
|
||||
// note 32 is the BitsPerPixel.
|
||||
this->pixelBuffer = new sf::Uint8[height * width * 4];
|
||||
// note the size of the buffer is multiplied by 4 due to rgba values
|
||||
this->window.create(this->videoMode, "ComSquare Emulator", sf::Style::Default);
|
||||
this->window.setFramerateLimit(maxFPS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user