-
Notifications
You must be signed in to change notification settings - Fork 0
/
Display.h
64 lines (45 loc) · 1.1 KB
/
Display.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
Display Class
This is a wrapper object that contains both a Window and a Renderer,
when creating graphics you should just need one of these to do all
the jobs you need.
This handles anything renderable including Interactables and text
This also supports z-ordering! The larger the number the further
forward it is.
*/
#pragma once
#ifdef _WIN32
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
#endif
#ifdef unix
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>
#endif
#include <list>
#include "Renderable.h"
class Display
{
std::list<Renderable*> renderList;
const char* title;
int w_ = 0;
int h_ = 0;
public:
SDL_Window* window;
SDL_Renderer* renderer;
SDL_Color backgroundColor = {0, 0, 0, 255};
public:
Display(int w, int h, const char* windowTitle, SDL_Color backgroundColor = { 0, 0, 0, 255 });
~Display();
static void init();
static void exit();
void RenderAll();
void AddRenderable(Renderable *toAdd);
void ProcessRender();
void PrepareRender();
void ClearRenderables();
int w() const { return w_; }
int h() const { return h_; }
};