Jagguar Game Engine

Loading...
Searching...
No Matches
IGraphicsEngineRenderer.hpp
1#ifndef GRAPHICS_ENGINE_RENDERER_HPP
2#define GRAPHICS_ENGINE_RENDERER_HPP
3// ==================== Libraries ==================
4// Depending on the operating system we use
5// The paths to SDL are actually different.
6// The #define statement should be passed in
7// when compiling using the -D argument.
8// This gives an example of how a programmer
9// may support multiple platforms with different
10// dependencies.
11//
12// Note that your path may be different depending on where you intalled things
13//
14//
15#if defined(LINUX) || defined(MINGW)
16#include <SDL2/SDL.h>
17#else // This works for Mac
18
19#include <SDL.h>
20
21#endif
22
27 class IGraphicsEngineRenderer {
28 public:
32 IGraphicsEngineRenderer(int w, int h) : mScreenWidth(w), mScreenHeight(h) {};
33
37 virtual ~IGraphicsEngineRenderer() {};
38
43 virtual void SetRenderDrawColor(int r, int g, int b, int a) = 0;
44
48 virtual void RenderClear() = 0;
49
54 virtual void RenderPresent() = 0;
55
56 protected:
57 // Screen dimension constants
58 int mScreenWidth{0};
59 int mScreenHeight{0};
60};
61
62
63 class SDLGraphicsEngineRenderer : public IGraphicsEngineRenderer {
64 public:
68 SDLGraphicsEngineRenderer(int w, int h);
69
73 ~SDLGraphicsEngineRenderer();
74
75 void SetRenderDrawColor(int r, int g, int b, int a) override;
76
80 void RenderClear() override;
81
86 void RenderPresent() override;
87
91 SDL_Window *GetWindow();
92
96 SDL_Renderer *GetRenderer();
97
98 private:
99 // SDL Window
100 SDL_Window *mWindow = nullptr;
101 // SDL Renderer
102 SDL_Renderer *mRenderer = nullptr;
103};
104
105#endif
IGraphicsEngineRenderer
Definition: IGraphicsEngineRenderer.hpp:27
IGraphicsEngineRenderer::~IGraphicsEngineRenderer
virtual ~IGraphicsEngineRenderer()
Definition: IGraphicsEngineRenderer.hpp:37
IGraphicsEngineRenderer::IGraphicsEngineRenderer
IGraphicsEngineRenderer(int w, int h)
Definition: IGraphicsEngineRenderer.hpp:32
IGraphicsEngineRenderer::RenderClear
virtual void RenderClear()=0
IGraphicsEngineRenderer::RenderPresent
virtual void RenderPresent()=0
IGraphicsEngineRenderer::SetRenderDrawColor
virtual void SetRenderDrawColor(int r, int g, int b, int a)=0
SDLGraphicsEngineRenderer
Definition: IGraphicsEngineRenderer.hpp:63
SDLGraphicsEngineRenderer::~SDLGraphicsEngineRenderer
~SDLGraphicsEngineRenderer()
Definition: IGraphicsEngineRenderer.cpp:49
SDLGraphicsEngineRenderer::SetRenderDrawColor
void SetRenderDrawColor(int r, int g, int b, int a) override
Definition: IGraphicsEngineRenderer.cpp:63
SDLGraphicsEngineRenderer::GetRenderer
SDL_Renderer * GetRenderer()
Definition: IGraphicsEngineRenderer.cpp:81
SDLGraphicsEngineRenderer::GetWindow
SDL_Window * GetWindow()
Definition: IGraphicsEngineRenderer.cpp:76
SDLGraphicsEngineRenderer::RenderPresent
void RenderPresent() override
Definition: IGraphicsEngineRenderer.cpp:71
SDLGraphicsEngineRenderer::RenderClear
void RenderClear() override
Definition: IGraphicsEngineRenderer.cpp:67