mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 23:07:18 +00:00
[client] fix the fps limiter
This commit is contained in:
parent
88dad36449
commit
4580b18b04
@ -148,32 +148,11 @@ static int renderThread(void * unused)
|
|||||||
/* signal to other threads that the renderer is ready */
|
/* signal to other threads that the renderer is ready */
|
||||||
lgSignalEvent(e_startup);
|
lgSignalEvent(e_startup);
|
||||||
|
|
||||||
unsigned int resyncCheck = 0;
|
|
||||||
struct timespec time;
|
struct timespec time;
|
||||||
clock_gettime(CLOCK_REALTIME, &time);
|
|
||||||
|
|
||||||
while(state.running)
|
while(state.running)
|
||||||
{
|
{
|
||||||
// if our clock is too far out of sync, resync it
|
clock_gettime(CLOCK_REALTIME, &time);
|
||||||
// this can happen when switching to/from a TTY, or due to clock drift
|
|
||||||
// we only check this once every 100 frames
|
|
||||||
if (state.frameTime > 0 && ++resyncCheck == 100)
|
|
||||||
{
|
|
||||||
resyncCheck = 0;
|
|
||||||
|
|
||||||
struct timespec tmp;
|
|
||||||
clock_gettime(CLOCK_REALTIME, &tmp);
|
|
||||||
if (tmp.tv_nsec - time.tv_nsec < 0)
|
|
||||||
{
|
|
||||||
tmp.tv_sec -= time.tv_sec - 1;
|
|
||||||
tmp.tv_nsec = 1000000000 + tmp.tv_nsec - time.tv_nsec;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tmp.tv_sec -= time.tv_sec;
|
|
||||||
tmp.tv_nsec -= time.tv_nsec;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state.lgrResize)
|
if (state.lgrResize)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user