-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSDLWrapper.hpp
More file actions
140 lines (111 loc) · 4.14 KB
/
Copy pathSDLWrapper.hpp
File metadata and controls
140 lines (111 loc) · 4.14 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#pragma once
#ifndef _SDLWRAPPER_H_
#define _SDLWRAPPER_H_
// Geometry
//
#include "IncludeGL.hpp"
// SDL
//
#include <SDL.h>
// STL
//
#include <iostream>
#include <string>
namespace Geometry
{
class TimeManager;
class SDLWrapper
{
public:
/* =============================================================
* ENUMS
* ============================================================= */
struct SimulationState
{
enum State
{
RUNNING = 1,
PAUSED = 2,
QUIT = 4
};
};
/* =============================================================
* CTOR
* ============================================================= */
SDLWrapper( const std::string& title, const int& width, const int& height );
/* =============================================================
* DTOR
* ============================================================= */
~SDLWrapper( );
/* =============================================================
* PUBLIC FUNCTIONS
* ============================================================= */
// SDL
//
bool OnInit ( );
void OnCleanup ( );
void OnResize ( int width, int height );
void OnExit ( );
//////////////////////////////////////////
// Simulation
//////////////////////////////////////////
// Heartbeat
//
void OnExecute ( );
void OnLoop ( );
/* =============================================================
* INLINE FUNCTIONS
* ============================================================= */
inline const bool IsRunning ( ) const { return m_state == SimulationState::RUNNING; }
private:
/* =============================================================
* MEMBERS
* ============================================================= */
std::string m_title;
int m_width;
int m_height;
unsigned int m_nUpdates;
double m_deltaTime;
SimulationState::State m_state;
// SDL
//
SDL_Surface* m_mainwindow;
// Utilities
//
TimeManager* m_timer;
/* =============================================================
* PRIVATE FUNCTIONS
* ============================================================= */
void OnUpdate ( );
void OnRender ( );
void OnInput ( );
/* =============================================================
* SDL INPUT HANDLING FUNCTIONS
* ============================================================= */
// Handlers
void HandleMouseButtonDownEvents ( SDL_Event* event );
void HandleMouseButtonUpEvents ( SDL_Event* event );
// Keyboard
//
void OnKeyDown ( SDL_KeyboardEvent keyBoardEvent );
void OnKeyUp ( SDL_KeyboardEvent keyBoardEvent );
// Touch
//
void OnFingerDown ( SDL_Event* touchFingerEvent );
void OnFingerUp ( SDL_Event* touchFingerEvent );
void OnFingerMotion ( SDL_Event* touchFingerEvent );
// Mouse
//
// Move
void OnMouseMove ( int x, int y, int relx, int rely, bool left, bool right, bool middle );
// Button down
void OnLButtonDown ( int x, int y);
void OnRButtonDown ( int x, int y);
void OnMButtonDown ( int x, int y);
// Button up
void OnLButtonUp ( int x, int y);
void OnRButtonUp ( int x, int y);
void OnMButtonUp ( int x, int y);
};
}
#endif // _SDLWRAPPER_H_