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

@ -114,8 +114,7 @@ main()
mfb_set_user_data(window, (void *) "Input Events Test");
for (;;)
{
do {
int i;
mfb_update_state state;
@ -143,7 +142,7 @@ main()
window = 0x0;
break;
}
}
} while(mfb_wait_sync(window));
return 0;
}

View File

@ -110,13 +110,11 @@ main()
mfb_set_user_data(window, (void *) "Input Events CPP Test");
for (;;)
{
do {
int i;
mfb_update_state state;
for (i = 0; i < WIDTH * HEIGHT; ++i)
{
for (i = 0; i < WIDTH * HEIGHT; ++i) {
noise = seed;
noise >>= 3;
noise ^= seed;
@ -133,7 +131,7 @@ main()
window = 0x0;
break;
}
}
} while(mfb_wait_sync(window));
return 0;
}

View File

@ -138,6 +138,8 @@ main()
pallete[64*7 + c] = MFB_RGB(255-col, 0, 0);
}
mfb_set_target_fps(10);
//--
float time = 0;
for (;;)
@ -191,6 +193,12 @@ main()
if(window_a == 0x0 && window_b == 0x0) {
break;
}
// Don't need to do this for both windows in the same thread
if(window_a != 0x0)
mfb_wait_sync(window_a);
else if(window_b != 0x0)
mfb_wait_sync(window_b);
}
return 0;

View File

@ -17,13 +17,11 @@ main()
if (!window)
return 0;
for (;;)
{
do {
int i;
mfb_update_state state;
for (i = 0; i < WIDTH * HEIGHT; ++i)
{
for (i = 0; i < WIDTH * HEIGHT; ++i) {
noise = seed;
noise >>= 3;
noise ^= seed;
@ -40,7 +38,7 @@ main()
window = 0x0;
break;
}
}
} while(mfb_wait_sync(window));
return 0;
}