Added mfb_get_target_fps
This commit is contained in:
parent
cc79a85e3d
commit
fb35e988ad
@ -136,10 +136,11 @@ double mfb_timer_get_frequency();
|
|||||||
double mfb_timer_get_resolution();
|
double mfb_timer_get_resolution();
|
||||||
```
|
```
|
||||||
|
|
||||||
Furthermore you can set a target fps for the application. The default is 60 frames per second.
|
Furthermore you can set (and get) a target fps for the application. The default is 60 frames per second.
|
||||||
|
|
||||||
```c
|
```c
|
||||||
void mfb_set_target_fps(uint32_t fps);
|
void mfb_set_target_fps(uint32_t fps);
|
||||||
|
unsigned mfb_get_target_fps();
|
||||||
```
|
```
|
||||||
|
|
||||||
This avoid the problem of update too fast the window collapsing the redrawing in fast processors.
|
This avoid the problem of update too fast the window collapsing the redrawing in fast processors.
|
||||||
|
@ -68,6 +68,7 @@ const uint8_t * mfb_get_key_buffer(struct mfb_window *window); // O
|
|||||||
|
|
||||||
// FPS
|
// FPS
|
||||||
void mfb_set_target_fps(uint32_t fps);
|
void mfb_set_target_fps(uint32_t fps);
|
||||||
|
unsigned mfb_get_target_fps();
|
||||||
bool mfb_wait_sync(struct mfb_window *window);
|
bool mfb_wait_sync(struct mfb_window *window);
|
||||||
|
|
||||||
// Timer
|
// Timer
|
||||||
|
@ -22,6 +22,17 @@ mfb_set_target_fps(uint32_t fps) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-------------------------------------
|
||||||
|
unsigned
|
||||||
|
mfb_get_target_fps() {
|
||||||
|
if (g_time_for_frame == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 1.0 / g_time_for_frame;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
struct mfb_timer *
|
struct mfb_timer *
|
||||||
mfb_timer_create() {
|
mfb_timer_create() {
|
||||||
|
Loading…
Reference in New Issue
Block a user