196 break; |
196 break; |
197 } |
197 } |
198 } |
198 } |
199 |
199 |
200 // compute frame time |
200 // compute frame time |
|
201 // TODO: think about whether frame rate is actually a per-window thing |
|
202 // the answer is hopefully NO, because that would mean behaviors are also a per-window thing |
201 uint64_t frame_nanos, ns; |
203 uint64_t frame_nanos, ns; |
202 do { |
204 do { |
203 ns = asc_nanos(); |
205 ns = asc_nanos(); |
204 frame_nanos = ns - asc_context.total_nanos; |
206 frame_nanos = ns - asc_context.total_nanos; |
205 } while (frame_nanos == 0); |
207 } while (frame_nanos == 0); |
206 asc_context.frame_nanos = frame_nanos; |
208 asc_context.frame_nanos = frame_nanos; |
|
209 unsigned long long fps_1k = asc_seconds(1000) / frame_nanos; |
|
210 asc_context.frame_rate = (float)fps_1k / 1000.f; |
|
211 if (asc_context.frame_rate < 5) { |
|
212 // effectively stop the world when the frame rate drops too low |
|
213 asc_context.frame_factor = 0; |
|
214 } else { |
|
215 asc_context.frame_factor = 1.f / asc_context.frame_rate; |
|
216 } |
207 asc_context.total_nanos = ns; |
217 asc_context.total_nanos = ns; |
208 |
218 |
209 // sync the windows |
219 // sync the windows |
210 for (unsigned int i = 0 ; i < ASC_MAX_WINDOWS ; i++) { |
220 for (unsigned int i = 0 ; i < ASC_MAX_WINDOWS ; i++) { |
211 asc_window_sync(i); |
221 asc_window_sync(i); |