Added SUPPORT_HALFBUSY_WAIT_LOOP
This commit is contained in:
parent
cff38308b7
commit
42d56d2f37
@ -48,6 +48,8 @@
|
|||||||
#define SUPPORT_MOUSE_CURSOR_RPI 1
|
#define SUPPORT_MOUSE_CURSOR_RPI 1
|
||||||
// Use busy wait loop for timing sync, if not defined, a high-resolution timer is setup and used
|
// Use busy wait loop for timing sync, if not defined, a high-resolution timer is setup and used
|
||||||
//#define SUPPORT_BUSY_WAIT_LOOP 1
|
//#define SUPPORT_BUSY_WAIT_LOOP 1
|
||||||
|
// Use a half-busy wait loop, in this case frame sleeps for some time and runs a busy-wait-loop at the end
|
||||||
|
//#define SUPPORT_HALFBUSY_WAIT_LOOP
|
||||||
// Wait for events passively (sleeping while no events) instead of polling them actively every frame
|
// Wait for events passively (sleeping while no events) instead of polling them actively every frame
|
||||||
//#define SUPPORT_EVENTS_WAITING 1
|
//#define SUPPORT_EVENTS_WAITING 1
|
||||||
// Allow automatic screen capture of current screen pressing F12, defined in KeyCallback()
|
// Allow automatic screen capture of current screen pressing F12, defined in KeyCallback()
|
||||||
|
13
src/core.c
13
src/core.c
@ -61,6 +61,9 @@
|
|||||||
* #define SUPPORT_BUSY_WAIT_LOOP
|
* #define SUPPORT_BUSY_WAIT_LOOP
|
||||||
* Use busy wait loop for timing sync, if not defined, a high-resolution timer is setup and used
|
* Use busy wait loop for timing sync, if not defined, a high-resolution timer is setup and used
|
||||||
*
|
*
|
||||||
|
* #define SUPPORT_HALFBUSY_WAIT_LOOP
|
||||||
|
* Use a half-busy wait loop, in this case frame sleeps for some time and runs a busy-wait-loop at the end
|
||||||
|
*
|
||||||
* #define SUPPORT_EVENTS_WAITING
|
* #define SUPPORT_EVENTS_WAITING
|
||||||
* Wait for events passively (sleeping while no events) instead of polling them actively every frame
|
* Wait for events passively (sleeping while no events) instead of polling them actively every frame
|
||||||
*
|
*
|
||||||
@ -3342,6 +3345,12 @@ static void Wait(float ms)
|
|||||||
// Busy wait loop
|
// Busy wait loop
|
||||||
while ((nextTime - prevTime) < ms/1000.0f) nextTime = GetTime();
|
while ((nextTime - prevTime) < ms/1000.0f) nextTime = GetTime();
|
||||||
#else
|
#else
|
||||||
|
#if defined(SUPPORT_HALFBUSY_WAIT_LOOP)
|
||||||
|
#define MAX_HALFBUSY_WAIT_TIME 4
|
||||||
|
double destTime = GetTime() + ms/1000;
|
||||||
|
if (ms > MAX_HALFBUSY_WAIT_TIME) ms -= MAX_HALFBUSY_WAIT_TIME;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
Sleep((unsigned int)ms);
|
Sleep((unsigned int)ms);
|
||||||
#elif defined(__linux__) || defined(PLATFORM_WEB)
|
#elif defined(__linux__) || defined(PLATFORM_WEB)
|
||||||
@ -3356,6 +3365,10 @@ static void Wait(float ms)
|
|||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
usleep(ms*1000.0f);
|
usleep(ms*1000.0f);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(SUPPORT_HALFBUSY_WAIT_LOOP)
|
||||||
|
while (GetTime() < destTime) { }
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user