Game Development Reference
In-Depth Information
Listing 6-16. Changes to Quake's Main Game Loop
// in sys_android.c Quake main function
int main (int c, char **v)
{
double time, oldtime, newtime;
// Quake initialization...
// We don't need this loop in Android
#ifdef HAVE_RENDER_LOOP
oldtime = Sys_FloatTime () - 0.1;
while (1)
{
newtime = Sys_FloatTime ();
time = newtime - oldtime;
if (cls.state == ca_dedicated)
{ // play vcrfiles at max speed
if (time < sys_ticrate.value ) // Vladimir && (vcrFile == -1 || recording) )
{
usleep(1);
continue; // not time to run a server only tic yet
}
time = sys_ticrate.value;
}
if (time > sys_ticrate.value*2)
oldtime = newtime;
else
oldtime += time;
Host_Frame (time);
// graphic debugging aids
if (sys_linerefresh.value)
Sys_LineRefresh ();
}
#endif
}
But you also need to implement onDrawFrame , which must perform all OpenGL operations
before swapping buffers. To do this, you simply take the code you commented out from
Quake's main function and put in its own function, called RenderFrame . This function essentially
renders a single frame of the game and will be called by the Java class Natives.RenderFrame ,
described in the “Java OpenGL Renderer Architecture” section earlier in this chapter.
 
Search WWH ::




Custom Search