diff options
author | Jack Palevich <jackpal@google.com> | 2010-12-16 19:06:00 -0800 |
---|---|---|
committer | Jack Palevich <jackpal@google.com> | 2010-12-16 19:06:00 -0800 |
commit | 296fe63c4f6f1f28e0e50b51f6aa8d92e1919991 (patch) | |
tree | 254e2a7a3bf3b517d0987cd5256469040ac50716 | |
parent | d6e5c0c7191348931592653048274a1091af1e5f (diff) | |
download | quake-296fe63c4f6f1f28e0e50b51f6aa8d92e1919991.tar.gz |
Avoid visual corruption if the game runs too fast.
If we run too fast while not in timedemo mode the game will
return immediately rather than rendering a frame.
If we go ahead and return to GLSurfaceView, it will swap the GL buffer
without having drawn anything into it, which will lead to garbage
being displayed.
The work-around is to detect that the game has decided to not render
anything, sleep for a ms and then try again.
Change-Id: Iba9d759547ddbc30534db963f5c47011038cc246
-rw-r--r-- | quake/src/WinQuake/host.cpp | 4 | ||||
-rw-r--r-- | quake/src/WinQuake/quakedef.h | 1 | ||||
-rw-r--r-- | quake/src/WinQuake/sys_android.cpp | 14 |
3 files changed, 17 insertions, 2 deletions
diff --git a/quake/src/WinQuake/host.cpp b/quake/src/WinQuake/host.cpp index 670d7a0..f1af56a 100644 --- a/quake/src/WinQuake/host.cpp +++ b/quake/src/WinQuake/host.cpp @@ -42,6 +42,7 @@ double host_time; double realtime; // without any filtering or bounding double oldrealtime; // last frame run int host_framecount; +qboolean host_framethrottled; // Running too fast int host_hunklevel; @@ -644,7 +645,8 @@ void _Host_Frame (float time) rand (); // decide the simulation time - if (!Host_FilterTime (time)) + host_framethrottled = !Host_FilterTime (time); + if (host_framethrottled) return; // don't run too fast, or packets will flood out // get new key events diff --git a/quake/src/WinQuake/quakedef.h b/quake/src/WinQuake/quakedef.h index 6b42720..807b47d 100644 --- a/quake/src/WinQuake/quakedef.h +++ b/quake/src/WinQuake/quakedef.h @@ -308,6 +308,7 @@ extern double host_frametime; extern byte *host_basepal; extern byte *host_colormap; extern int host_framecount; // incremented every frame, never reset +extern qboolean host_framethrottled; // Running too fast extern double realtime; // not bounded in any way, changed at // start of every frame, never reset diff --git a/quake/src/WinQuake/sys_android.cpp b/quake/src/WinQuake/sys_android.cpp index 1537814..c66f01c 100644 --- a/quake/src/WinQuake/sys_android.cpp +++ b/quake/src/WinQuake/sys_android.cpp @@ -622,7 +622,7 @@ static void UpdateFrameTimes(float time) currentFrame++; } -int AndroidStep(int width, int height) +int AndroidStepImp(int width, int height) { // PMPBEGIN(("AndroidStep")); double time, newtime; @@ -645,6 +645,18 @@ int AndroidStep(int width, int height) return key_dest == key_game; } +int AndroidStep(int width, int height) +{ + for(;;) { + host_framethrottled = false; + int result = AndroidStepImp(width, height); + if (!host_framethrottled) { + return result; + } + usleep(1000); + } +} + extern void Host_Quit(); void AndroidQuit() { soft_quit = true; |