SimpleGL  1.1.0
A framework for platform independent rendering
application.hpp
Go to the documentation of this file.
1 
8 #ifndef APPLICATION_HPP
9 #define APPLICATION_HPP
10 
11 #include "SimpleGL_Export.h"
12 
13 #include <vector>
14 
15 #include "glfw_window.hpp"
16 #include "event.hpp"
17 
18 namespace sgl {
19 
25  class SIMPLEGL_EXPORT Application {
26 
27  protected:
29  bool running;
30 
32  int targetUps;
33 
35  int targetFps;
36 
39 
41  Application(void);
42 
43  public:
45  ~Application(void);
46 
48  void run();
49 
51  void init();
52 
54  void mainLoop();
55 
61  virtual void handleEvents(std::vector<Event*> events) = 0;
62 
68  virtual void updateScene(float delta) = 0;
69 
71  virtual void clear() = 0;
72 
78  virtual void renderScene(float alpha) = 0;
79 
81  virtual void dispose();
82  };
83 
89  class SIMPLEGL_EXPORT TimeUtil {
90 
91  private:
93  static double lastLoopTime;
94 
96  static float timeCount;
97 
99  static int fps;
100 
102  static int fpsCount;
103 
105  static int ups;
106 
108  static int upsCount;
109 
111  TimeUtil(void);
112 
113  public:
115  static void init();
116 
122  static double getTime();
123 
129  static float getDelta();
130 
132  static void update();
133 
135  static void incFPS();
136 
138  static void incUPS();
139 
145  static int getFPS();
146 
152  static int getUPS();
153 
159  static double getLastLoopTime();
160  };
161 }
162 
163 #endif /* APPLICATION_HPP */
Window * window
The window of this application.
Definition: application.hpp:38
This class provides a basic GLFW window.
Definition: glfw_window.hpp:29
Generic namespace for the SimpleGL framework.
Definition: application.hpp:18
SIMPLEGL_EXPORT void init()
Initializes SimpleGL and should be called before anything else.
Definition: core.cpp:20
int targetUps
Stores the desired UPS.
Definition: application.hpp:32
bool running
Tells if the application is running.
Definition: application.hpp:29
This class contains static methods for time calculations.
Definition: application.hpp:89
This is the base class for an application.
Definition: application.hpp:25
int targetFps
Stores the desired FPS.
Definition: application.hpp:35