aboutsummaryrefslogtreecommitdiffstats
path: root/LibOVR/Src/Util
diff options
context:
space:
mode:
Diffstat (limited to 'LibOVR/Src/Util')
-rw-r--r--LibOVR/Src/Util/Util_LongPollThread.cpp96
-rw-r--r--LibOVR/Src/Util/Util_LongPollThread.h72
-rw-r--r--LibOVR/Src/Util/Util_Render_Stereo.cpp22
-rw-r--r--LibOVR/Src/Util/Util_Settings.cpp312
-rw-r--r--LibOVR/Src/Util/Util_Settings.h83
5 files changed, 12 insertions, 573 deletions
diff --git a/LibOVR/Src/Util/Util_LongPollThread.cpp b/LibOVR/Src/Util/Util_LongPollThread.cpp
deleted file mode 100644
index c7c5c5d..0000000
--- a/LibOVR/Src/Util/Util_LongPollThread.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/************************************************************************************
-
-Filename : Util_LongPollThread.cpp
-Content : Allows us to do all long polling tasks from a single thread to minimize deadlock risk
-Created : June 30, 2013
-Authors : Chris Taylor
-
-Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
-
-Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
-you may not use the Oculus VR Rift SDK except in compliance with the License,
-which is provided at the time of installation or download, or which
-otherwise accompanies this software in either electronic or hard copy form.
-
-You may obtain a copy of the License at
-
-http://www.oculusvr.com/licenses/LICENSE-3.1
-
-Unless required by applicable law or agreed to in writing, the Oculus VR SDK
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-*************************************************************************************/
-
-#include "Util_LongPollThread.h"
-#include "Util_Watchdog.h"
-
-OVR_DEFINE_SINGLETON(OVR::Util::LongPollThread);
-
-namespace OVR { namespace Util {
-
-
-void LongPollThread::AddPollFunc(Observer<PollFunc>* func)
-{
- func->Observe(PollSubject);
-}
-
-LongPollThread::LongPollThread() :
- Terminated(false)
-{
- Start();
-
- PushDestroyCallbacks();
-}
-
-LongPollThread::~LongPollThread()
-{
- fireTermination();
-
- Join();
-}
-
-void LongPollThread::OnThreadDestroy()
-{
- fireTermination();
-}
-
-void LongPollThread::Wake()
-{
- WakeEvent.SetEvent();
-}
-
-void LongPollThread::fireTermination()
-{
- Terminated = true;
- Wake();
-}
-
-void LongPollThread::OnSystemDestroy()
-{
- Release();
-}
-
-int LongPollThread::Run()
-{
- SetThreadName("LongPoll");
- WatchDog watchdog("LongPoll");
-
- // While not terminated,
- do
- {
- watchdog.Feed(10000);
-
- PollSubject->Call();
-
- WakeEvent.Wait(WakeupInterval);
- WakeEvent.ResetEvent();
- } while (!Terminated);
-
- return 0;
-}
-
-
-}} // namespace OVR::Util
diff --git a/LibOVR/Src/Util/Util_LongPollThread.h b/LibOVR/Src/Util/Util_LongPollThread.h
deleted file mode 100644
index 5183e2f..0000000
--- a/LibOVR/Src/Util/Util_LongPollThread.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/************************************************************************************
-
-Filename : Util_LongPollThread.h
-Content : Allows us to do all long polling tasks from a single thread to minimize deadlock risk
-Created : June 30, 2013
-Authors : Chris Taylor
-
-Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
-
-Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
-you may not use the Oculus VR Rift SDK except in compliance with the License,
-which is provided at the time of installation or download, or which
-otherwise accompanies this software in either electronic or hard copy form.
-
-You may obtain a copy of the License at
-
-http://www.oculusvr.com/licenses/LICENSE-3.1
-
-Unless required by applicable law or agreed to in writing, the Oculus VR SDK
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-*************************************************************************************/
-
-#ifndef OVR_Util_LongPollThread_h
-#define OVR_Util_LongPollThread_h
-
-#include "../Kernel/OVR_Timer.h"
-#include "../Kernel/OVR_Atomic.h"
-#include "../Kernel/OVR_Allocator.h"
-#include "../Kernel/OVR_String.h"
-#include "../Kernel/OVR_System.h"
-#include "../Kernel/OVR_Threads.h"
-#include "../Kernel/OVR_Observer.h"
-
-namespace OVR { namespace Util {
-
-
-//-----------------------------------------------------------------------------
-// LongPollThread
-
-// This thread runs long-polling subsystems that wake up every second or so
-// The motivation is to reduce the number of threads that are running to minimize the risk of deadlock
-class LongPollThread : public Thread, public SystemSingletonBase<LongPollThread>
-{
- OVR_DECLARE_SINGLETON(LongPollThread);
- virtual void OnThreadDestroy();
-
-public:
- typedef Delegate0<void> PollFunc;
- static const int WakeupInterval = 1000; // milliseconds
-
- void AddPollFunc(Observer<PollFunc>* func);
-
- void Wake();
-
-protected:
- ObserverScope<PollFunc> PollSubject;
-
- bool Terminated;
- Event WakeEvent;
- void fireTermination();
-
- virtual int Run();
-};
-
-
-}} // namespace OVR::Util
-
-#endif // OVR_Util_LongPollThread_h
diff --git a/LibOVR/Src/Util/Util_Render_Stereo.cpp b/LibOVR/Src/Util/Util_Render_Stereo.cpp
index 6937141..1389462 100644
--- a/LibOVR/Src/Util/Util_Render_Stereo.cpp
+++ b/LibOVR/Src/Util/Util_Render_Stereo.cpp
@@ -545,8 +545,10 @@ void StereoConfig::UpdateComputedState()
eyeTypes[1] = StereoEye_Right;
break;
- default:
- OVR_ASSERT( false ); break;
+ default:
+ numEyes = 0;
+ OVR_ASSERT( false );
+ break;
}
// If either of these fire, you've probably forgotten to call SetRendertargetSize()
@@ -1069,14 +1071,14 @@ void HeightmapMeshCreate( HeightmapMeshVertexData **ppVertices, uint16_t **ppTri
}
// Populate vertex buffer info
- float xOffset = 0.0f;
- float uOffset = 0.0f;
-
- if (rightEye)
- {
- xOffset = 1.0f;
- uOffset = 0.5f;
- }
+ //float xOffset = 0.0f; Not currently used.
+ //float uOffset = 0.0f;
+
+ //if (rightEye)
+ //{
+ // xOffset = 1.0f;
+ // uOffset = 0.5f;
+ //}
// First pass - build up raw vertex data.
HeightmapMeshVertexData* pcurVert = *ppVertices;
diff --git a/LibOVR/Src/Util/Util_Settings.cpp b/LibOVR/Src/Util/Util_Settings.cpp
deleted file mode 100644
index d7b3f0d..0000000
--- a/LibOVR/Src/Util/Util_Settings.cpp
+++ /dev/null
@@ -1,312 +0,0 @@
-/************************************************************************************
-
-Filename : Util_Settings.cpp
-Content : Persistent settings subsystem
-Created : June 11, 2014
-Author : Chris Taylor
-
-Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
-
-Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
-you may not use the Oculus VR Rift SDK except in compliance with the License,
-which is provided at the time of installation or download, or which
-otherwise accompanies this software in either electronic or hard copy form.
-
-You may obtain a copy of the License at
-
-http://www.oculusvr.com/licenses/LICENSE-3.1
-
-Unless required by applicable law or agreed to in writing, the Oculus VR SDK
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-************************************************************************************/
-
-#include "Util_Settings.h"
-#include "../OVR_Profile.h"
-
-OVR_DEFINE_SINGLETON(Util::Settings);
-
-namespace OVR { namespace Util {
-
-
-//// Settings
-
-Settings::Settings() :
- Dirty(false)
-{
- // Set up long poll handler
- PollObserver.SetHandler(LongPollThread::PollFunc::FromMember<Settings, &Settings::pollDirty>(this));
- LongPollThread::GetInstance()->AddPollFunc(PollObserver);
-
- PushDestroyCallbacks();
-}
-
-Settings::~Settings()
-{
- PollObserver.ReleaseAll();
-
- Lock::Locker locker(&DataLock);
-
- if (Dirty)
- {
- updateFile();
- Dirty = false;
- }
-}
-
-void Settings::OnSystemDestroy()
-{
- delete this;
-}
-
-void Settings::SetFileName(const String& fileName)
-{
- Lock::Locker locker(&DataLock);
-
- OVR_ASSERT(FullFilePath.IsEmpty());
-
- if (FullFilePath.IsEmpty())
- {
- FullFilePath = GetBaseOVRPath(true) + "/" + fileName;
-
- loadFile();
- }
-}
-
-void Settings::loadFile()
-{
- Root = *JSON::Load(FullFilePath.ToCStr());
- if (!Root)
- {
- OVR_DEBUG_LOG(("[Settings] Settings file was empty"));
- }
- else
- {
- OVR_DEBUG_LOG(("[Settings] Successfully read settings file"));
- }
-}
-
-void Settings::updateFile()
-{
- OVR_ASSERT(!FullFilePath.IsEmpty());
-
- if (Root->Save(FullFilePath.ToCStr()))
- {
- OVR_DEBUG_LOG(("[Settings] Updated settings file: %s", FullFilePath.ToCStr()));
- Dirty = false;
- }
- else
- {
- LogError("[Settings] WARNING: Unable to write settings file: %s", FullFilePath.ToCStr());
- OVR_ASSERT(false);
- }
-}
-
-void Settings::pollDirty()
-{
- // If dirty,
- if (Dirty)
- {
- Lock::Locker locker(&DataLock);
-
- if (!Dirty)
- {
- return;
- }
-
- updateFile();
- }
-}
-
-void Settings::SetNumber(const char* key, double value)
-{
- Lock::Locker locker(&DataLock);
-
- Dirty = true;
-
- if (!Root)
- {
- Root = *JSON::CreateObject();
- }
-
- Ptr<JSON> item = Root->GetItemByName(key);
- if (!item)
- {
- Root->AddNumberItem(key, value);
- return;
- }
-
- item->Type = JSON_Number;
- item->dValue = value;
-}
-
-void Settings::SetInt(const char* key, int value)
-{
- Lock::Locker locker(&DataLock);
-
- if (!Root)
- {
- Root = *JSON::CreateObject();
- Dirty = true;
- }
-
- Ptr<JSON> item = Root->GetItemByName(key);
- if (!item)
- {
- Root->AddIntItem(key, value);
- Dirty = true;
- return;
- }
-
- // If the value changed,
- if (item->Type != JSON_Number ||
- (int)item->dValue != value)
- {
- item->Type = JSON_Number;
- item->dValue = value;
- Dirty = true;
- }
-}
-
-void Settings::SetBool(const char* key, bool value)
-{
- Lock::Locker locker(&DataLock);
-
- if (!Root)
- {
- Root = *JSON::CreateObject();
- Dirty = true;
- }
-
- Ptr<JSON> item = Root->GetItemByName(key);
- if (!item)
- {
- Root->AddBoolItem(key, value);
- Dirty = true;
- return;
- }
-
- // If the value changed,
- if (item->Type != JSON_Bool ||
- ((int)item->dValue != 0) != value)
- {
- item->Type = JSON_Bool;
- item->dValue = value ? 1. : 0.;
- item->Value = value ? "true" : "false";
- Dirty = true;
- }
-}
-
-void Settings::SetString(const char* key, const char* value)
-{
- Lock::Locker locker(&DataLock);
-
- if (!Root)
- {
- Root = *JSON::CreateObject();
- Dirty = true;
- }
-
- Ptr<JSON> item = Root->GetItemByName(key);
- if (!item)
- {
- Root->AddStringItem(key, value);
- Dirty = true;
- return;
- }
-
- // If the value changed,
- if (item->Type != JSON_String ||
- item->Value != value)
- {
- item->Type = JSON_String;
- item->Value = value;
- Dirty = true;
- }
-}
-
-double Settings::GetNumber(const char* key, double defaultValue)
-{
- Lock::Locker locker(&DataLock);
-
- if (!Root)
- {
- SetNumber(key, defaultValue);
- return defaultValue;
- }
-
- Ptr<JSON> item = Root->GetItemByName(key);
- if (!item)
- {
- SetNumber(key, defaultValue);
- return defaultValue;
- }
-
- return item->dValue;
-}
-
-int Settings::GetInt(const char* key, int defaultValue)
-{
- Lock::Locker locker(&DataLock);
-
- if (!Root)
- {
- SetInt(key, defaultValue);
- return defaultValue;
- }
-
- Ptr<JSON> item = Root->GetItemByName(key);
- if (!item)
- {
- SetInt(key, defaultValue);
- return defaultValue;
- }
-
- return (int)item->dValue;
-}
-
-bool Settings::GetBool(const char* key, bool defaultValue)
-{
- Lock::Locker locker(&DataLock);
-
- if (!Root)
- {
- SetBool(key, defaultValue);
- return defaultValue;
- }
-
- Ptr<JSON> item = Root->GetItemByName(key);
- if (!item)
- {
- SetBool(key, defaultValue);
- return defaultValue;
- }
-
- return (int)item->dValue != 0;
-}
-
-String Settings::GetString(const char* key, const char* defaultValue)
-{
- Lock::Locker locker(&DataLock);
-
- if (!Root)
- {
- SetString(key, defaultValue);
- return defaultValue;
- }
-
- Ptr<JSON> item = Root->GetItemByName(key);
- if (!item)
- {
- SetString(key, defaultValue);
- return defaultValue;
- }
-
- return item->Value;
-}
-
-
-}} // namespace OVR::Util
diff --git a/LibOVR/Src/Util/Util_Settings.h b/LibOVR/Src/Util/Util_Settings.h
deleted file mode 100644
index 79ea172..0000000
--- a/LibOVR/Src/Util/Util_Settings.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/************************************************************************************
-
-PublicHeader: n/a
-Filename : Util_Settings.h
-Content : Persistent settings subsystem
-Created : June 11, 2014
-Author : Chris Taylor
-
-Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
-
-Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
-you may not use the Oculus VR Rift SDK except in compliance with the License,
-which is provided at the time of installation or download, or which
-otherwise accompanies this software in either electronic or hard copy form.
-
-You may obtain a copy of the License at
-
-http://www.oculusvr.com/licenses/LICENSE-3.1
-
-Unless required by applicable law or agreed to in writing, the Oculus VR SDK
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-************************************************************************************/
-
-#ifndef OVR_Settings_h
-#define OVR_Settings_h
-
-#include "../Kernel/OVR_String.h"
-#include "../Kernel/OVR_System.h"
-#include "../Kernel/OVR_Observer.h"
-#include "../OVR_JSON.h"
-#include "Util_LongPollThread.h"
-
-namespace OVR { namespace Util {
-
-
-//-----------------------------------------------------------------------------
-// Settings
-
-class Settings : public NewOverrideBase, public SystemSingletonBase<Settings>
-{
- OVR_DECLARE_SINGLETON(Settings);
-
- ObserverScope<LongPollThread::PollFunc> PollObserver;
- void pollDirty();
-
- // Helpers (call with lock held)
- void loadFile();
- void updateFile();
-
- // Synchronization for data access
- Lock DataLock;
-
- // Full path to the JSON settings file
- String FullFilePath;
-
- // Backed by JSON
- Ptr<JSON> Root;
-
- // Dirty flag to capture multiple changes for long poll writes
- bool Dirty;
-
-public:
- void SetFileName(const String& fileName);
-
- void SetNumber(const char* key, double value);
- void SetInt(const char* key, int value);
- void SetBool(const char* key, bool value);
- void SetString(const char* key, const char* value);
-
- double GetNumber(const char* key, double defaultValue = 0.);
- int GetInt(const char* key, int defaultValue = 0);
- bool GetBool(const char* key, bool defaultValue = false);
- String GetString(const char* key, const char* defaultValue = "");
-};
-
-
-}} // namespace OVR::Util
-
-#endif // OVR_Settings_h