// // Created by anonymus-raccoon on 2/15/20. // #ifndef COMSQUARE_QTSFML_HPP #define COMSQUARE_QTSFML_HPP #include #include #include #include "../IRenderer.hpp" #include "../SFRenderer.hpp" #include "QtWidgetSFML.hpp" namespace ComSquare::Renderer { //! @brief The SFML window that manage the update. class QtFullSFML : public QtWidgetSFML { private: //! @brief The snes to update. SNES &_snes; void _onUpdate() override; public: QtFullSFML(SNES &snes, QWidget* parent, const QPoint& position, const QSize& size, int frameRate = 0); QtFullSFML(const QtFullSFML &) = delete; QtFullSFML &operator=(const QtFullSFML &) = delete; ~QtFullSFML() override = default; }; //! @brief A SFML renderer inside a QT window. class QtSFML : public IRenderer { private: //! @brief The QT app instance. QApplication &_app; //! @brief The SFML frame. QFrame *frame{}; //! @brief The SFML widget. QtFullSFML *_sfWidget{}; //! @brief The width of the window. unsigned int width; //! @brief The height of the window. unsigned int height; public: //! @brief Use this function to create the window. //! @param maxFPS The number of FPS you aim to run on. void createWindow(SNES &snes, int maxFPS) override; //! @brief Set a new name to the window, if there is already a name it will be overwrite. //! @param newWindowName new title for the window. void setWindowName(std::string newWindowName) override; //! @brief Add a pixel to the buffer to the coordinates x, y with the color rgba. //! @param X horizontal index. //! @param Y vertical index. //! @param rgba The color of the pixel. void putPixel(unsigned y, unsigned x, uint32_t rgba) override; //! @brief This function doesn't do anything because QT internally handle drawing to the screen. void drawScreen() override; //! @brief Constructor that return a SFML renderer inside a QT window. //! @param height height of the window. //! @param width width of the window. QtSFML(QApplication &app, unsigned int height, unsigned int width); QtSFML(const QtSFML &) = delete; QtSFML &operator=(const QtSFML &) = delete; ~QtSFML() = default; }; } #endif //COMSQUARE_QTSFML_HPP