if (state->savedState != NULL) {
// We are starting with a previous saved state; restore from it.
engine.state = *(struct saved_state*)state->savedState;
}
int ident, events;
struct android_poll_source* source;
while (true)
{
while ((ident = ALooper_pollAll(0, NULL, &events, (void**)&source)) >= 0)
{
if (source != NULL)
source->process(state, source);
if (state->destroyRequested != 0)
return;
}
engine_draw_frame(&engine);
}
}
效果如图所示。