20 |
#include "log.hpp" |
#include "log.hpp" |
21 |
#include "texture.hpp" |
#include "texture.hpp" |
22 |
#include "scene-manager.hpp" |
#include "scene-manager.hpp" |
23 |
#include <stdexcept> |
#include "exception_types.hpp" |
24 |
#include <boost/format.hpp> |
#include <boost/format.hpp> |
25 |
#include <boost/filesystem/operations.hpp> |
#include <boost/filesystem/operations.hpp> |
26 |
#include <memory> |
#include <memory> |
28 |
namespace usata |
namespace usata |
29 |
{ |
{ |
30 |
|
|
31 |
|
class Clocker |
32 |
|
{ |
33 |
|
unsigned cnt; |
34 |
|
unsigned int next; |
35 |
|
public: |
36 |
|
bool try_next(); |
37 |
|
void xsync(); |
38 |
|
}; |
39 |
|
|
40 |
|
bool |
41 |
|
Clocker::try_next() |
42 |
|
{ |
43 |
|
if (system::time::get_ticks()>= next) |
44 |
|
{ |
45 |
|
next +=16; |
46 |
|
++cnt; |
47 |
|
if (cnt >= 3) |
48 |
|
{ |
49 |
|
cnt=0; |
50 |
|
++next; |
51 |
|
} |
52 |
|
return true; |
53 |
|
} |
54 |
|
|
55 |
|
return false; |
56 |
|
} |
57 |
|
|
58 |
|
void |
59 |
|
Clocker::xsync() |
60 |
|
{ |
61 |
|
next=system::time::get_ticks(); |
62 |
|
cnt=0; |
63 |
|
} |
64 |
|
|
65 |
|
|
66 |
namespace |
namespace |
67 |
{ |
{ |
68 |
|
|
103 |
: texture_manager(new TextureManager), |
: texture_manager(new TextureManager), |
104 |
scene(new SceneManager) |
scene(new SceneManager) |
105 |
{ |
{ |
106 |
|
|
107 |
} |
} |
108 |
|
|
109 |
Usata::~Usata() |
Usata::~Usata() |
141 |
} |
} |
142 |
|
|
143 |
int |
int |
144 |
|
Usata::loop() |
145 |
|
{ |
146 |
|
Clocker clock; |
147 |
|
clock.xsync(); |
148 |
|
quit = false; |
149 |
|
|
150 |
|
unsigned int cnt=0; |
151 |
|
|
152 |
|
while (!quit) |
153 |
|
{ |
154 |
|
while (clock.try_next()) |
155 |
|
++cnt; |
156 |
|
|
157 |
|
if (cnt > 60) |
158 |
|
quit=true; |
159 |
|
|
160 |
|
} |
161 |
|
|
162 |
|
return 0; |
163 |
|
} |
164 |
|
|
165 |
|
int |
166 |
Usata::run() |
Usata::run() |
167 |
{ |
{ |
168 |
log::BufferedStream logstream; |
log::BufferedStream logstream; |
176 |
|
|
177 |
//texture_manager->get("atex"); |
//texture_manager->get("atex"); |
178 |
|
|
179 |
return 0; |
return loop(); |
180 |
} |
} |
181 |
|
|
182 |
|
|
183 |
|
|
184 |
} // namespace usata |
} // namespace usata |