/** * Process the next main command. */ void Engine::handleCommand(int32_t cmd) { switch (cmd) { case APP_CMD_START: break; // The window is being shown, get it ready. case APP_CMD_INIT_WINDOW: case APP_CMD_WINDOW_RESIZED: mEGL->setWindow(mApp->window); break; case APP_CMD_TERM_WINDOW: // The window is being hidden or closed, clean it up. mEGL->setWindow(NULL); break; case APP_CMD_GAINED_FOCUS: if (mAppBase) mAppBase->focusChanged(true); requestForceRender(); break; case APP_CMD_LOST_FOCUS: if (mAppBase) mAppBase->focusChanged(false); requestForceRender(); break; case APP_CMD_PAUSE: requestForceRender(); break; // ICS does not appear to require this, but on GB phones, // not having this causes rotation changes to be delayed or // ignored when we're in a non-rendering mode like autopause. // The forced renders appear to allow GB to process the rotation case APP_CMD_CONFIG_CHANGED: requestForceRender(); break; case APP_CMD_SAVE_STATE: // The system has asked us to save our current state. Do so. mApp->savedState = malloc(sizeof(struct saved_state)); *((struct saved_state*)mApp->savedState) = mState; mApp->savedStateSize = sizeof(struct saved_state); break; case APP_CMD_DESTROY: break; } }
void Engine::setAppUIMode(unsigned int mode) { if (mCurrentMode != mode) requestForceRender(); mCurrentMode = mode; }
void Engine::setGameplayMode(bool running) { if (mGameplayMode != running) requestForceRender(); mGameplayMode = running; }
void Engine::handleCommand(int cmd) { switch (cmd) { // The window is being shown, get it ready. // Note that on ICS, the EGL size will often be correct for the new size here // But on HC it will not be. We need to defer checking the new res until the // first render with the new surface! case APP_CMD_INIT_WINDOW: case APP_CMD_WINDOW_RESIZED: mEgl.setWindow(mApp->window); requestForceRender(); break; case APP_CMD_TERM_WINDOW: // The window is being hidden or closed, clean it up. mEgl.setWindow(NULL); break; case APP_CMD_GAINED_FOCUS: requestForceRender(); break; case APP_CMD_LOST_FOCUS: // Move out of gameplay mode if we are in it. But if we are // in another dialog mode, leave it as-is if (mCurrentMode == MODE_GAMEPLAY) setAppUIMode(MODE_AUTOPAUSE); requestForceRender(); break; case APP_CMD_PAUSE: if (mCurrentMode == MODE_GAMEPLAY) setAppUIMode(MODE_AUTOPAUSE); requestForceRender(); break; // ICS does not appear to require this, but on GB phones, // not having this causes rotation changes to be delayed or // ignored when we're in a non-rendering mode like autopause. // The forced renders appear to allow GB to process the rotation case APP_CMD_CONFIG_CHANGED: requestForceRender(); break; } }
bool Engine::hasWindowResized() { if (mEGL->checkWindowResized()) { requestForceRender(); return true; } return false; }
bool Engine::checkWindowResized() { if (mEgl.checkWindowResized()) { mResizePending = true; requestForceRender(); LOGI("Window size change %dx%d", mEgl.getWidth(), mEgl.getHeight()); return true; } return false; }