Exemplo n.º 1
0
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;
    }
}
Exemplo n.º 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();
    }
}
Exemplo n.º 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;
}
bool InstancedTessellation::handleGamepadChanged(uint32_t changedPadFlags) {
    if (changedPadFlags) {
        NvGamepad* pad = getPlatformContext()->getGamepad();
        if (!pad) return false;

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

    return false;
}
Exemplo n.º 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;
}
Exemplo n.º 6
0
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;
}
Exemplo n.º 7
0
void NvAppBase::appRequestExit() {
    getPlatformContext()->requestExit();
    m_requestedExit = true; 
}