Dynacoe.h
1 /*
2 
3 Copyright (c) 2018, Johnathan Corkery. (jcorkery@umich.edu)
4 All rights reserved.
5 
6 This file is part of the Dynacoe project (https://github.com/jcorks/Dynacoe)
7 Dynacoe was released under the MIT License, as detailed below.
8 
9 
10 
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is furnished
16 to do so, subject to the following conditions:
17 
18 The above copyright notice and this permission notice shall
19 be included in all copies or substantial portions of the Software.
20 
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 DEALINGS IN THE SOFTWARE.
28 
29 
30 
31 */
32 
33 #ifndef H_CB_MAIN_INCLUDED
34 #define H_CB_MAIN_INCLUDED
35 
36 
37 
38 
39 
40 
41 
42 #include <Dynacoe/Components/Clock.h>
43 #include <Dynacoe/Entity.h>
44 #include <cstdlib>
45 #include <sstream>
46 #include <iostream>
47 
48 
49 namespace Dynacoe {
50 class Universe;
51 class Module;
55 class Engine {
56 
57 
58  public:
59 
60 
68  static int Startup();
69 
70 
79  static void AddModule(Module *);
80 
81 
87  static int Run();
88 
94  static Entity::ID & Root();
95 
98  static void AttachManager(Entity::ID);
99 
102  static void Quit();
103 
104 
110  static void Wait(int FPS);
111 
112 
113 
116  static void SetMaxFPS(int i);
117 
120  static int GetMaxFPS();
121 
125  static std::string GetBaseDirectory();
126 
129  static std::string Version();
130 
131 
132 
133  struct Diagnostics {
134  float drawTimeMS;
135  float stepTimeMS;
136  float systemTimeMS;
137  float engineRealTimeMS;
138  int currentFPS;
139  };
140 
141  static const Diagnostics & GetDiagnostics();
142 
143  private:
144 
145 
146 
147 
148  static double frameStart;
149  static double frameEnd;
150 
151  static bool EXIT;
152 
153 
154 
155 
156 
157 
158  static std::vector<Module*> modules;
159 
160  static Dynacoe::Clock drawTime;
161  static Dynacoe::Clock runTime;
162  static Dynacoe::Clock sysTime;
163  static Dynacoe::Clock debugTime;
164  static Dynacoe::Clock frameTime;
165 
166  static float lastDrawTime;
167  static float lastRunTime;
168  static float lastSysTime;
169  static float lastDebugTime;
170 
171  static float curDrawTime;
172  static float curRunTime;
173  static float curSysTime;
174  static float curDebugTime;
175 
176  static int frameCount;
177  static int valid;
178 
179  static void render();
180  static void update();
181 
182  static std::vector<Entity*> worlds;
183  static Entity::ID universe;
184  static Entity * systemWorld;
185 };
186 };
187 
188 #endif // H_CB_MAIN_INCLUDED
static int GetMaxFPS()
Gets the maximum FPS allowable by the Engine.
Basic interactive object.
Definition: Entity.h:62
static void Quit()
Ends the Engine execution loop.
Definition: AssetID.h:37
Timing class with millisecond resolution.
Definition: Clock.h:59
static int Run()
Begins the Engine execution loop.
static std::string Version()
Returns the version of the Dynacoe library as a whole.
static void Wait(int FPS)
Sleeps until the time required for the target frames-per-second is reached.
static void AddModule(Module *)
static std::string GetBaseDirectory()
Returns the starting directory of Dynacoe.
static int Startup()
Initializes all Dynacoe assets.
static Entity::ID & Root()
Returns the toplevel Entity.
static void SetMaxFPS(int i)
Sets the ideal frame per second that the main loop should clock at.
Uniquely identifies an Entity.
Definition: Entity.h:67
Main class that handles automated updates of Dynacoe.
Definition: Dynacoe.h:55
static void AttachManager(Entity::ID)
Attaches a management-type entity.