Last active
November 8, 2019 16:51
-
-
Save untodesu/ca9958ad1dbbd040b95a8a42811b4700 to your computer and use it in GitHub Desktop.
render
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "render.hh" | |
| using namespace std; | |
| using namespace sf; | |
| namespace aux2d | |
| { | |
| namespace game | |
| { | |
| /// IRenderer implementation | |
| class Renderer : public IRenderer { | |
| private: | |
| VideoMode m_VideoMode; | |
| Uint32 m_WindowStyle; | |
| string m_Title; | |
| public: | |
| void init(const VideoMode &mode, const string &title, const Uint32 style); | |
| void start(); | |
| private: | |
| void loopThreaded(); | |
| }; | |
| /// Initialize renderer | |
| void Renderer::init(const VideoMode &mode, const string &title, const Uint32 style) | |
| { | |
| m_Title = title; | |
| m_VideoMode = mode; | |
| m_WindowStyle = style; | |
| } | |
| /// Start rendering loop | |
| void Renderer::start() | |
| { | |
| Thread renderThread(&Renderer::loopThreaded, this); | |
| renderThread.launch(); | |
| } | |
| /// Render loop | |
| void Renderer::loopThreaded() | |
| { | |
| //DO STUFF | |
| } | |
| static Renderer renderer; | |
| IRenderer *render() | |
| { | |
| return (IRenderer *)&renderer; | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <string> | |
| #include <SFML/Graphics.hpp> | |
| #include <SFML/System.hpp> | |
| #include <SFML/Window.hpp> | |
| namespace aux2d | |
| { | |
| namespace game | |
| { | |
| /// Renderer interface | |
| class IRenderer { | |
| public: | |
| /// Initialize. | |
| virtual void init(const sf::VideoMode &mode, const std::string &title, const sf::Uint32 style) = 0; | |
| /// Start render loop | |
| virtual void start() = 0; | |
| }; | |
| /// Singleton accessor | |
| IRenderer *render(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment