コード例 #1
0
void NativeEngine::KillContext() {
    LOGD("NativeEngine: killing context.");

    // since the context is going away, we have to kill the GL objects
    KillGLObjects();

    eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);

    if (mEglContext != EGL_NO_CONTEXT) {
        eglDestroyContext(mEglDisplay, mEglContext);
        mEglContext = EGL_NO_CONTEXT;
    }
    LOGD("NativeEngine: Context killed successfully.");
}
コード例 #2
0
ファイル: native_engine.cpp プロジェクト: Uliori/Origami
void NativeEngine::HandleCommand(int32_t cmd) {
//    SceneManager *mgr = SceneManager::GetInstance();

    OLog("NativeEngine: handling command " << cmd);
    switch (cmd) {
        case APP_CMD_SAVE_STATE:
            // The system has asked us to save our current state.
            OLog("NativeEngine: APP_CMD_SAVE_STATE");
            mApp->savedState = malloc(sizeof(mState));
            *((NativeEngineSavedState*)mApp->savedState) = mState;
            mApp->savedStateSize = sizeof(mState);
            break;
        case APP_CMD_INIT_WINDOW:
            // We have a window!
            OLog("NativeEngine: APP_CMD_INIT_WINDOW");
            if (mApp->window != NULL) {
                mHasWindow = true;
            }
            break;
        case APP_CMD_TERM_WINDOW:
            // The window is going away -- kill the surface
            OLog("NativeEngine: APP_CMD_TERM_WINDOW");
            KillSurface();
            mHasWindow = false;
            break;
        case APP_CMD_GAINED_FOCUS:
            OLog("NativeEngine: APP_CMD_GAINED_FOCUS");
            mHasFocus = true;
            Game::instance()->setPaused(false);//test
            break;
        case APP_CMD_LOST_FOCUS:
            OLog("NativeEngine: APP_CMD_LOST_FOCUS");
            mHasFocus = false;
            Game::instance()->setPaused(true);//test
            break;
        case APP_CMD_PAUSE:
            OLog("NativeEngine: APP_CMD_PAUSE");
            Game::instance()->setPaused(true);
            break;
        case APP_CMD_RESUME:
            OLog("NativeEngine: APP_CMD_RESUME");
            Game::instance()->setPaused(false);
            break;
        case APP_CMD_STOP:
            OLog("NativeEngine: APP_CMD_STOP");
            mIsVisible = false;
            break;
        case APP_CMD_START:
            OLog("NativeEngine: APP_CMD_START");
            mIsVisible = true;
            break;
        case APP_CMD_WINDOW_RESIZED:
        case APP_CMD_CONFIG_CHANGED:
            OLog("NativeEngine: " << (cmd == APP_CMD_WINDOW_RESIZED) ?
                    "APP_CMD_WINDOW_RESIZED" : "APP_CMD_CONFIG_CHANGED");
            // Window was resized or some other configuration changed.
            // Note: we don't handle this event because we check the surface dimensions
            // every frame, so that's how we know it was resized. If you are NOT doing that,
            // then you need to handle this event!
            break;
        case APP_CMD_LOW_MEMORY:
            OLog("NativeEngine: APP_CMD_LOW_MEMORY");
            // system told us we have low memory. So if we are not visible, let's
            // cooperate by deallocating all of our graphic resources.
            if (!mHasWindow) {
                OLog("NativeEngine: trimming memory footprint (deleting GL objects).");
                KillGLObjects();
            }
            break;
        default:
            OLog("NativeEngine: (unknown command).");
            break;
    }

//    VLOGD("NativeEngine: STATUS: F%d, V%d, W%d, EGL: D %p, S %p, CTX %p, CFG %p",
//            mHasFocus, mIsVisible, mHasWindow, mEglDisplay, mEglSurface, mEglContext, mEglConfig);
}