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; } }
void MultiDrawIndirect::shutdownRendering(void) { // If we still have a bound context, then it makes sense to delete GL resources if (getPlatformContext()->isContextBound()) { CleanRendering(); } }
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; }
bool ParticleUpsampling::handleGamepadChanged(uint32_t changedPadFlags) { if (changedPadFlags) { NvGamepad* pad = getPlatformContext()->getGamepad(); if (!pad) return false; LOGI("gamepads: 0x%08x", changedPadFlags); } return false; }
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; }
void NvAppBase::appRequestExit() { getPlatformContext()->requestExit(); m_requestedExit = true; }