Game Engine 2D Platformer
GraphicsEngineRenderer.hpp
Go to the documentation of this file.
1 /*
2  * @file GraphicsEngineRenderer.hpp
3  * @brief GraphicsEngineRenderer class interface
4  * @date 2021-03-12
5  ***********************************************/
6 #ifndef GRAPHICS_ENGINE_RENDERER_HPP
7 #define GRAPHICS_ENGINE_RENDERER_HPP
8 // ==================== Libraries ==================
9 // Depending on the operating system we use
10 // The paths to SDL are actually different.
11 // The #define statement should be passed in
12 // when compiling using the -D argument.
13 // This gives an example of how a programmer
14 // may support multiple platforms with different
15 // dependencies.
16 //
17 // Note that your path may be different depending on where you intalled things
18 //
19 //
20 #if defined(LINUX) || defined(MINGW)
21 #include <SDL2/SDL.h>
22 #else // This works for Mac
23 #include <SDL.h>
24 #endif
25 #include <SDL2_image/SDL_image.h>
26 #include "ResourceManager.hpp"
27 
33 {
34 public:
40  GraphicsEngineRenderer(int w, int h, std::string path);
49  void render(int x, int y, SDL_Rect *clip = NULL, double angle = 0.0, SDL_Point *center = NULL, SDL_RendererFlip flip = SDL_FLIP_NONE);
53  void SetRenderDrawColor();
54  void SetTexture();
55 
56  void RenderClear();
57 
62  void RenderPresent();
66  SDL_Window *GetWindow();
70  SDL_Renderer *GetRenderer();
74  void SetNewTexture(std::string path);
78  int getWidth();
82  int getHeight();
83 
84 private:
85  // Screen dimension constants
86  int m_screenHeight;
87  int m_screenWidth;
88  int textureWidth = 0;
89  int textureHeight = 0;
90  std::string path;
91  //SDL Texture background Image
92  SDL_Texture *textureBG;
93  // SDL Window
94  SDL_Window *m_window;
95  // SDL Renderer
96  SDL_Renderer *m_renderer = nullptr;
97  SDL_Rect renderQuad;
98  //Create a ResourceManager instance
100 };
101 
102 #endif
This class serves as an interface to the main graphics renderer for our engine.
Definition: GraphicsEngineRenderer.hpp:33
void render(int x, int y, SDL_Rect *clip=NULL, double angle=0.0, SDL_Point *center=NULL, SDL_RendererFlip flip=SDL_FLIP_NONE)
Set the color for the background whenever the color is cleared.
Definition: GraphicsEngineRenderer.cpp:98
int getHeight()
Get Height of texture.
Definition: GraphicsEngineRenderer.cpp:159
int getWidth()
Get Width of texture.
Definition: GraphicsEngineRenderer.cpp:155
void SetNewTexture(std::string path)
Set new texture.
Definition: GraphicsEngineRenderer.cpp:143
void SetTexture()
Definition: GraphicsEngineRenderer.cpp:163
GraphicsEngineRenderer(int w, int h, std::string path)
Constuctor for GraphicsEngineRenderer. Takes in an int for width and height, and a file path as a str...
Definition: GraphicsEngineRenderer.cpp:15
SDL_Window * GetWindow()
Get Pointer to Window.
Definition: GraphicsEngineRenderer.cpp:132
void RenderClear()
Definition: GraphicsEngineRenderer.cpp:121
void SetRenderDrawColor()
Clear the screen.
Definition: GraphicsEngineRenderer.cpp:116
SDL_Renderer * GetRenderer()
Get Pointer to Renderer.
Definition: GraphicsEngineRenderer.cpp:138
void RenderPresent()
Render whatever is in the backbuffer to the screen.
Definition: GraphicsEngineRenderer.cpp:126
~GraphicsEngineRenderer()
Destructor.
Definition: GraphicsEngineRenderer.cpp:83
The resource manager is responsible for handling and managing resources regarding the game.
Definition: ResourceManager.hpp:23
static ResourceManager & getInstance()
Method used to get instance of ResourceManager class.
Definition: ResourceManager.cpp:8