adding init/shutdown for plugin init

This commit is contained in:
Wayne Chen 2019-01-28 14:35:41 -08:00
parent c06f2f337e
commit 0f1aebea82
4 changed files with 24 additions and 4 deletions

View file

@ -800,6 +800,10 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
if (auto steamClient = pluginManager->getSteamClientPlugin()) {
steamClient->init();
}
if (auto oculusPlatform = pluginManager->getOculusPlatformPlugin()) {
oculusPlatform->init();
}
PROFILE_SET_THREAD_NAME("Main Thread");
#if defined(Q_OS_WIN)
@ -2667,6 +2671,10 @@ Application::~Application() {
steamClient->shutdown();
}
if (auto oculusPlatform = PluginManager::getInstance()->getOculusPlatformPlugin()) {
oculusPlatform->shutdown();
}
DependencyManager::destroy<PluginManager>();
DependencyManager::destroy<CompositorHelper>(); // must be destroyed before the FramebufferCache

View file

@ -20,6 +20,9 @@ public:
virtual QString getName() const = 0;
virtual QString getOculusUserID() const = 0;
virtual bool init() = 0;
virtual void shutdown() = 0;
virtual bool isRunning() const = 0;
virtual void requestNonceAndUserID(NonceUserIDCallback callback) = 0;

View file

@ -17,13 +17,18 @@
QString OculusAPIPlugin::NAME { "Oculus Rift" };
OculusAPIPlugin::OculusAPIPlugin() {
if (hifi::ovr::available()) {
_session = hifi::ovr::acquireRenderSession();
}
}
OculusAPIPlugin::~OculusAPIPlugin() {
if (hifi::ovr::available() && isRunning()) {
}
bool OculusAPIPlugin::init() {
_session = hifi::ovr::acquireRenderSession();
return _session;
}
void OculusAPIPlugin::shutdown() {
if (isRunning()) {
hifi::ovr::releaseRenderSession(_session);
}
}

View file

@ -23,6 +23,10 @@ public:
bool isRunning() const;
bool init();
void shutdown();
virtual void requestNonceAndUserID(NonceUserIDCallback callback);
virtual void handleOVREvents();