Unravel Engine C++ Reference
|
Class responsible for timers. More...
#include <simulation.h>
Public Types | |
using | clock_t = std::chrono::steady_clock |
using | timepoint_t = clock_t::time_point |
using | duration_t = clock_t::duration |
using | delta_t = std::chrono::duration<float> |
Public Member Functions | |
simulation () | |
void | run_one_frame (bool is_active) |
Perform on frame computations with specified fps. | |
auto | get_frame () const -> uint64_t |
void | set_min_fps (uint32_t fps) |
Set minimum frames per second. If fps goes lower than this, time will appear to slow. | |
void | set_max_fps (uint32_t fps) |
Set maximum frames per second. The engine will sleep if fps is higher than this. | |
void | set_max_inactive_fps (uint32_t fps) |
Set maximum frames per second when the application does not have input focus. | |
void | set_time_smoothing_step (uint32_t step) |
Set how many frames to average for timestep smoothing. | |
auto | get_time_since_launch () const -> duration_t |
Returns duration since launch. | |
auto | get_fps () const -> float |
Returns frames per second. | |
auto | get_delta_time () const -> delta_t |
Returns the delta time in seconds. | |
void | set_time_scale (float time_scale=1.0f) |
auto | get_time_scale () const -> float |
Protected Attributes | |
float | time_scale_ {1.0f} |
uint32_t | min_fps_ = 0 |
minimum/maximum frames per second | |
uint32_t | max_fps_ = 0 |
uint32_t | max_inactive_fps_ = 20 |
std::vector< duration_t > | previous_timesteps_ |
previous time steps for smoothing in seconds | |
duration_t | timestep_ = duration_t::zero() |
next frame time step in seconds | |
uint64_t | frame_ = 0 |
current frame | |
uint32_t | smoothing_step_ = 11 |
how many frames to average for the smoothed time step | |
timepoint_t | last_frame_timepoint_ = clock_t::now() |
frame update timer | |
timepoint_t | launch_timepoint_ = clock_t::now() |
time point when we launched | |
Class responsible for timers.
Definition at line 19 of file simulation.h.
using unravel::simulation::clock_t = std::chrono::steady_clock |
Definition at line 21 of file simulation.h.
using unravel::simulation::delta_t = std::chrono::duration<float> |
Definition at line 24 of file simulation.h.
using unravel::simulation::duration_t = clock_t::duration |
Definition at line 23 of file simulation.h.
using unravel::simulation::timepoint_t = clock_t::time_point |
Definition at line 22 of file simulation.h.
unravel::simulation::simulation | ( | ) |
Definition at line 10 of file simulation.cpp.
auto unravel::simulation::get_delta_time | ( | ) | const -> delta_t |
Returns the delta time in seconds.
Definition at line 139 of file simulation.cpp.
auto unravel::simulation::get_fps | ( | ) | const -> float |
Returns frames per second.
Definition at line 133 of file simulation.cpp.
auto unravel::simulation::get_frame | ( | ) | const -> uint64_t |
Definition at line 103 of file simulation.cpp.
auto unravel::simulation::get_time_scale | ( | ) | const -> float |
Definition at line 150 of file simulation.cpp.
auto unravel::simulation::get_time_since_launch | ( | ) | const -> duration_t |
Returns duration since launch.
Definition at line 128 of file simulation.cpp.
void unravel::simulation::run_one_frame | ( | bool | is_active | ) |
Perform on frame computations with specified fps.
Definition at line 18 of file simulation.cpp.
void unravel::simulation::set_max_fps | ( | uint32_t | fps | ) |
Set maximum frames per second. The engine will sleep if fps is higher than this.
Definition at line 113 of file simulation.cpp.
void unravel::simulation::set_max_inactive_fps | ( | uint32_t | fps | ) |
Set maximum frames per second when the application does not have input focus.
Definition at line 118 of file simulation.cpp.
void unravel::simulation::set_min_fps | ( | uint32_t | fps | ) |
Set minimum frames per second. If fps goes lower than this, time will appear to slow.
Definition at line 108 of file simulation.cpp.
void unravel::simulation::set_time_scale | ( | float | time_scale = 1.0f | ) |
Definition at line 145 of file simulation.cpp.
void unravel::simulation::set_time_smoothing_step | ( | uint32_t | step | ) |
Set how many frames to average for timestep smoothing.
Definition at line 123 of file simulation.cpp.
|
protected |
current frame
Definition at line 123 of file simulation.h.
|
protected |
frame update timer
Definition at line 127 of file simulation.h.
|
protected |
time point when we launched
Definition at line 129 of file simulation.h.
|
protected |
Definition at line 115 of file simulation.h.
|
protected |
Definition at line 117 of file simulation.h.
|
protected |
minimum/maximum frames per second
Definition at line 113 of file simulation.h.
|
protected |
previous time steps for smoothing in seconds
Definition at line 119 of file simulation.h.
|
protected |
how many frames to average for the smoothed time step
Definition at line 125 of file simulation.h.
|
protected |
Definition at line 111 of file simulation.h.
|
protected |
next frame time step in seconds
Definition at line 121 of file simulation.h.