Framerate limit
This commit is contained in:
@@ -175,6 +175,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
f64 start = p_time();
|
f64 start = p_time();
|
||||||
f64 prev_t = 0;
|
f64 prev_t = 0;
|
||||||
|
f32 max_render_time = 1.0 / 30.0;
|
||||||
|
f64 processing_start = 0;
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
// Engine
|
// Engine
|
||||||
@@ -183,6 +185,13 @@ int main(int argc, char *argv[])
|
|||||||
//LOG(LOG_INFO, "Frame time: %.3lf ms FPS: %.2lf", 1000*delta_t, 1/delta_t);
|
//LOG(LOG_INFO, "Frame time: %.3lf ms FPS: %.2lf", 1000*delta_t, 1/delta_t);
|
||||||
r_time_update(engine.time);
|
r_time_update(engine.time);
|
||||||
|
|
||||||
|
// @Hack: @Performance: Reduced framerate to use less resources. Text rendering is highly inefficient right now. Maybe it will improve later and this will not be necessary anymore.
|
||||||
|
f64 processing_time = engine.time - processing_start;
|
||||||
|
if(processing_time < max_render_time)
|
||||||
|
p_wait(maximum(0, (max_render_time - 1.02*processing_time) * 1000));
|
||||||
|
processing_start = p_time() - start;
|
||||||
|
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
bool exit = process_input();
|
bool exit = process_input();
|
||||||
if(exit)
|
if(exit)
|
||||||
|
|||||||
Reference in New Issue
Block a user