コード例 #1
0
ファイル: NvAppBase.cpp プロジェクト: 151706061/OpenGLSamples
void NvAppBase::mainLoop() {
    bool hasInitializedGL = false;

    while (getPlatformContext()->isAppRunning() && !isExiting()) {
        bool needsReshape = false;

        getPlatformContext()->pollEvents(this);

        NvPlatformContext* ctx = getPlatformContext();

        update();

        // If the context has been lost and graphics resources are still around,
        // signal for them to be deleted
        if (ctx->isContextLost()) {
            if (hasInitializedGL) {
                shutdownRendering();
                hasInitializedGL = false;
            }
        }

        // If we're ready to render (i.e. the GL is ready and we're focused), then go ahead
        if (ctx->shouldRender()) {
            // If we've not (re-)initialized the resources, do it
            if (!hasInitializedGL) {
                NvImage::setAPIVersion(getGLContext()->getConfiguration().apiVer);

                initRendering();
                hasInitializedGL = true;
                needsReshape = true;
            } else if (ctx->hasWindowResized()) {
                needsReshape = true;
            }

            if (needsReshape) {
                reshape(getGLContext()->width(), getGLContext()->height());
            }

            if (!isExiting()) {
                draw();

                getGLContext()->swap();
            }
        }
    }

    if (hasInitializedGL) {
        shutdownRendering();
        hasInitializedGL = false;
    }
}
コード例 #2
0
void MultiDrawIndirect::shutdownRendering(void)
{
    // If we still have a bound context, then it makes sense to delete GL resources

    if (getPlatformContext()->isContextBound())
    {
        CleanRendering();
    }
}
コード例 #3
0
bool ComputeBasicGLSL::handleGamepadChanged(uint32_t changedPadFlags) {
    if (changedPadFlags) {
        NvGamepad* pad = getPlatformContext()->getGamepad();
        if (!pad) return false;

        LOGI("gamepads: 0x%08x", changedPadFlags);
    }

    return false;
}
コード例 #4
0
bool InstancedTessellation::handleGamepadChanged(uint32_t changedPadFlags) {
    if (changedPadFlags) {
        NvGamepad* pad = getPlatformContext()->getGamepad();
        if (!pad) return false;

        LOGI("gamepads: 0x%08x", changedPadFlags);
    }

    return false;
}
コード例 #5
0
bool ParticleUpsampling::handleGamepadChanged(uint32_t changedPadFlags) {
    if (changedPadFlags) {
        NvGamepad* pad = getPlatformContext()->getGamepad();
        if (!pad) return false;

        LOGI("gamepads: 0x%08x", changedPadFlags);
    }

    return false;
}
コード例 #6
0
ファイル: MainAndroid.cpp プロジェクト: James-Z/OpenGLSamples
bool NvAppBase::showDialog(const char* title, const char *contents, bool exitApp) {
    Engine* engine = (Engine*)getPlatformContext();
    struct android_app* app = engine->mApp;

       jstring jniTitle = app->appThreadEnv->NewStringUTF(title);
    EXCEPTION_RETURN(app->appThreadEnv);

       jstring jniContents = app->appThreadEnv->NewStringUTF(contents);
    EXCEPTION_RETURN(app->appThreadEnv);

    jclass thisClass = app->appThreadEnv->GetObjectClass(app->appThreadThis);
    EXCEPTION_RETURN(app->appThreadEnv);

    jmethodID showToastAlert = app->appThreadEnv->GetMethodID(thisClass, 
        "showAlert", "(Ljava/lang/String;Ljava/lang/String;Z)V");
    EXCEPTION_RETURN(app->appThreadEnv);

    app->appThreadEnv->CallVoidMethod(app->appThreadThis, showToastAlert, jniTitle, jniContents, exitApp);
    EXCEPTION_RETURN(app->appThreadEnv);

    return true;
}
コード例 #7
0
ファイル: NvAppBase.cpp プロジェクト: 151706061/OpenGLSamples
void NvAppBase::appRequestExit() {
    getPlatformContext()->requestExit();
    m_requestedExit = true; 
}