Platformer
Platformer
RenderManager.hpp
1 #ifndef RENDER_MANAGER_HPP
2 #define RENDER_MANAGER_HPP
3 
4 #include <SDL2/SDL.h>
5 #include <SDL2/SDL_image.h>
6 #include <SDL2/SDL_ttf.h>
7 
8 #include "ImageRenderComponent.hpp"
9 #include "TextRenderComponent.hpp"
10 
16  public:
18  static RenderManager& instance();
19 
25  bool init(
26  int screenWidth,
28  int screenHeight);
29 
33  void shutdown();
34 
38  void Render();
39 
44  static SDL_Renderer* GetRenderer();
45 
50  static std::shared_ptr<CameraComponent> GetCamera();
51 
53  static void SetActiveCamera(
54  std::shared_ptr<CameraComponent> camera);
55 
60  static int getWidth();
61 
66  static int getHeight();
67 
69  RenderManager(const RenderManager&) = delete;
70 
72  RenderManager& operator=(const RenderManager&) = delete;
73 
74  private:
76  RenderManager();
77 
80 
83 
86 
88  SDL_Window* gWindow;
89 
91  SDL_Renderer* gRenderer;
92 
94  std::shared_ptr<CameraComponent> camera_;
95 };
96 
97 #endif
int screenWidth_
The width of the screen.
Definition: RenderManager.hpp:82
static int getWidth()
Gets the screen width.
Definition: RenderManager.cpp:92
static RenderManager & instance()
The singleton instance of the RenderManager.
Definition: RenderManager.cpp:12
static SDL_Renderer * GetRenderer()
Gets the SDL_Renderer.
Definition: RenderManager.cpp:96
void Render()
Render the game.
Definition: RenderManager.cpp:106
RenderManager & operator=(const RenderManager &)=delete
Stop the compiler from generating methods to copy the object.
~RenderManager()
Destructs a RenderManager.
Definition: RenderManager.cpp:10
SDL_Window * gWindow
The window we&#39;ll be rendering to.
Definition: RenderManager.hpp:88
static int getHeight()
Gets the screen height.
Definition: RenderManager.cpp:94
SDL_Renderer * gRenderer
The SDL_Renderer for this instance.
Definition: RenderManager.hpp:91
RenderManager()
Constructs a RenderManager.
Definition: RenderManager.cpp:9
std::shared_ptr< CameraComponent > camera_
The Camera to use to render game objects.
Definition: RenderManager.hpp:94
This class manages the rendering of images in our game as a singleton.
Definition: RenderManager.hpp:15
bool init(int screenWidth, int screenHeight)
Initializes the render manager, SDL, and TTF, and creates the SDL_Window and SDL_Renderer.
Definition: RenderManager.cpp:18
int screenHeight_
The height of the screen.
Definition: RenderManager.hpp:85
static void SetActiveCamera(std::shared_ptr< CameraComponent > camera)
Sets the current active camera.
Definition: RenderManager.cpp:101
static std::shared_ptr< CameraComponent > GetCamera()
Gets the current active camera.
Definition: RenderManager.cpp:98
void shutdown()
Shuts down the render manager, SDL, and TTF.
Definition: RenderManager.cpp:79