Add timers and ability to set a target fps for the application (#36)

* working on windows

* minor fix

* working on macosx

* Oops! I reversed resolution and frequency on macos

* working on X11

* working on wayland

* update the readme

* format the readme

Co-authored-by: Carlos Aragones <>
This commit is contained in:
Carlos Aragonés
2020-04-22 13:00:15 +02:00
committed by GitHub
parent 4175cec89e
commit 35b8439b26
19 changed files with 734 additions and 239 deletions

View File

@ -56,6 +56,17 @@ float mfb_get_mouse_scroll_y(struct mfb_window *window); // M
const uint8_t * mfb_get_mouse_button_buffer(struct mfb_window *window); // One byte for every button. Press (1), Release 0. (up to 8 buttons)
const uint8_t * mfb_get_key_buffer(struct mfb_window *window); // One byte for every key. Press (1), Release 0.
void mfb_set_target_fps(uint32_t fps);
bool mfb_wait_sync(struct mfb_window *window);
struct mfb_timer * mfb_timer_create();
void mfb_timer_destroy(struct mfb_timer *tmr);
void mfb_timer_reset(struct mfb_timer *tmr);
double mfb_timer_now(struct mfb_timer *tmr);
double mfb_timer_delta(struct mfb_timer *tmr);
double mfb_timer_get_frequency();
double mfb_timer_get_resolution();
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus

View File

@ -172,6 +172,7 @@ typedef enum {
// Opaque pointer
struct mfb_window;
struct mfb_timer;
// Event callbacks
typedef void(*mfb_active_func)(struct mfb_window *window, bool isActive);