diff --git a/code/nel/include/nel/3d/stereo_ovr.h b/code/nel/include/nel/3d/stereo_ovr.h
new file mode 100644
index 000000000..ce61c1c2e
--- /dev/null
+++ b/code/nel/include/nel/3d/stereo_ovr.h
@@ -0,0 +1,96 @@
+/**
+ * \file stereo_ovr.h
+ * \brief CStereoOVR
+ * \date 2013-06-25 22:22GMT
+ * \author Jan Boon (Kaetemi)
+ * CStereoOVR
+ */
+
+/*
+ * Copyright (C) 2013 by authors
+ *
+ * This file is part of NL3D.
+ * NL3D is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * NL3D is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with NL3D. If not, see
+ * .
+ *
+ * Linking this library statically or dynamically with other modules
+ * is making a combined work based on this library. Thus, the terms
+ * and conditions of the GNU General Public License cover the whole
+ * combination.
+ *
+ * As a special exception, the copyright holders of this library give
+ * you permission to link this library with the Oculus SDK to produce
+ * an executable, regardless of the license terms of the Oculus SDK,
+ * and distribute linked combinations including the two, provided that
+ * you also meet the terms and conditions of the license of the Oculus
+ * SDK. You must obey the GNU General Public License in all respects
+ * for all of the code used other than the Oculus SDK. If you modify
+ * this file, you may extend this exception to your version of the
+ * file, but you are not obligated to do so. If you do not wish to do
+ * so, delete this exception statement from your version.
+ */
+
+#ifndef NL3D_STEREO_OVR_H
+#define NL3D_STEREO_OVR_H
+#include
+
+// STL includes
+
+// NeL includes
+#include
+
+// Project includes
+
+namespace NL3D {
+
+struct CStereoDeviceInfo
+{
+public:
+ uint8 Class;
+ uint8 Identifier;
+ NLMISC::CSmartPtr Factory;
+
+ std::string Manufacturer;
+ std::string ProductName;
+};
+
+class CStereoOVRDevicePtr;
+
+/**
+ * \brief CStereoOVR
+ * \date 2013-06-25 22:22GMT
+ * \author Jan Boon (Kaetemi)
+ * CStereoOVR
+ */
+class CStereoOVR
+{
+public:
+ CStereoOVR(const CStereoDeviceInfo &deviceInfo);
+ virtual ~CStereoOVR();
+
+ static void listDevices(std::vector &devicesOut);
+ static CStereoOVR *createDevice(const CStereoDeviceInfo &deviceInfo);
+ static bool isLibraryInUse();
+ static void releaseLibrary();
+
+private:
+ CStereoOVRDevicePtr *m_DevicePtr;
+
+}; /* class CStereoOVR */
+
+} /* namespace NL3D */
+
+#endif /* #ifndef NL3D_STEREO_OVR_H */
+
+/* end of file */
diff --git a/code/nel/src/3d/stereo_ovr.cpp b/code/nel/src/3d/stereo_ovr.cpp
new file mode 100644
index 000000000..c11d38774
--- /dev/null
+++ b/code/nel/src/3d/stereo_ovr.cpp
@@ -0,0 +1,209 @@
+/**
+ * \file stereo_ovr.cpp
+ * \brief CStereoOVR
+ * \date 2013-06-25 22:22GMT
+ * \author Jan Boon (Kaetemi)
+ * CStereoOVR
+ */
+
+/*
+ * Copyright (C) 2013 by authors
+ *
+ * This file is part of NL3D.
+ * NL3D is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * NL3D is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with NL3D. If not, see
+ * .
+ *
+ * Linking this library statically or dynamically with other modules
+ * is making a combined work based on this library. Thus, the terms
+ * and conditions of the GNU General Public License cover the whole
+ * combination.
+ *
+ * As a special exception, the copyright holders of this library give
+ * you permission to link this library with the Oculus SDK to produce
+ * an executable, regardless of the license terms of the Oculus SDK,
+ * and distribute linked combinations including the two, provided that
+ * you also meet the terms and conditions of the license of the Oculus
+ * SDK. You must obey the GNU General Public License in all respects
+ * for all of the code used other than the Oculus SDK. If you modify
+ * this file, you may extend this exception to your version of the
+ * file, but you are not obligated to do so. If you do not wish to do
+ * so, delete this exception statement from your version.
+ */
+
+#include
+#include
+
+// STL includes
+
+// External includes
+#include
+
+// NeL includes
+// #include
+
+// Project includes
+
+using namespace std;
+// using namespace NLMISC;
+
+namespace NL3D {
+
+namespace {
+
+class CStereoOVRLog : public OVR::Log
+{
+public:
+ CStereoOVRLog(unsigned logMask = OVR::LogMask_All) : OVR::Log(logMask)
+ {
+
+ }
+
+ virtual void LogMessageVarg(OVR::LogMessageType messageType, const char* fmt, va_list argList)
+ {
+ if (NLMISC::INelContext::isContextInitialised())
+ {
+ char buffer[MaxLogBufferMessageSize];
+ FormatLog(buffer, MaxLogBufferMessageSize, messageType, fmt, argList);
+ if (IsDebugMessage(messageType))
+ NLMISC::INelContext::getInstance().getDebugLog()->displayNL("OVR: %s", buffer);
+ else
+ NLMISC::INelContext::getInstance().getInfoLog()->displayNL("OVR: %s", buffer);
+ }
+ }
+};
+
+CStereoOVRLog *s_StereoOVRLog = NULL;
+OVR::Ptr s_DeviceManager;
+
+class CStereoOVRSystem
+{
+public:
+ ~CStereoOVRSystem()
+ {
+ Release();
+ }
+
+ void Init()
+ {
+ if (!s_StereoOVRLog)
+ {
+ nldebug("Initialize OVR");
+ s_StereoOVRLog = new CStereoOVRLog();
+ }
+ if (!OVR::System::IsInitialized())
+ OVR::System::Init(s_StereoOVRLog);
+ if (!s_DeviceManager)
+ s_DeviceManager = OVR::DeviceManager::Create();
+ }
+
+ void Release()
+ {
+ if (s_DeviceManager)
+ {
+ nldebug("Release OVR");
+ s_DeviceManager->Release();
+ }
+ s_DeviceManager.Clear();
+ if (OVR::System::IsInitialized())
+ OVR::System::Destroy();
+ if (s_StereoOVRLog)
+ nldebug("Release OVR Ok");
+ delete s_StereoOVRLog;
+ s_StereoOVRLog = NULL;
+ }
+};
+
+CStereoOVRSystem s_StereoOVRSystem;
+
+class CStereoOVRDeviceHandle : public NLMISC::CRefCount
+{
+public:
+ OVR::DeviceHandle DeviceHandle;
+};
+
+sint s_DeviceCounter = 0;
+
+}
+
+class CStereoOVRDevicePtr
+{
+public:
+ OVR::Ptr HMDDevice;
+};
+
+CStereoOVR::CStereoOVR(const CStereoDeviceInfo &deviceInfo)
+{
+ ++s_DeviceCounter;
+ m_DevicePtr = new CStereoOVRDevicePtr();
+
+ // CStereoOVRDeviceHandle *handle = static_cast(deviceInfo.Factory.getPtr());
+ // OVR::DeviceHandle dh = handle->DeviceHandle;
+ // dh.CreateDevice();
+}
+
+CStereoOVR::~CStereoOVR()
+{
+ // ...
+
+ delete m_DevicePtr;
+ m_DevicePtr = NULL;
+ --s_DeviceCounter;
+}
+
+void CStereoOVR::listDevices(std::vector &devicesOut)
+{
+ s_StereoOVRSystem.Init();
+ OVR::DeviceEnumerator devices = s_DeviceManager->EnumerateDevices();
+ uint8 id = 1;
+ do
+ {
+ CStereoDeviceInfo deviceInfoOut;
+ OVR::DeviceInfo deviceInfo;
+ if (devices.IsAvailable())
+ {
+ devices.GetDeviceInfo(&deviceInfo);
+ CStereoOVRDeviceHandle *handle = new CStereoOVRDeviceHandle();
+ deviceInfoOut.Factory = static_cast(handle);
+ handle->DeviceHandle = devices;
+ deviceInfoOut.Class = 1; // OVR::HMDDevice
+ deviceInfoOut.Identifier = id;
+ deviceInfoOut.Manufacturer = deviceInfo.Manufacturer;
+ deviceInfoOut.ProductName = deviceInfo.ProductName;
+ devicesOut.push_back(deviceInfoOut);
+ ++id;
+ }
+
+ } while (devices.Next());
+}
+
+CStereoOVR *CStereoOVR::createDevice(const CStereoDeviceInfo &deviceInfo)
+{
+ return NULL;
+}
+
+bool CStereoOVR::isLibraryInUse()
+{
+ nlassert(s_DeviceCounter >= 0);
+ return s_DeviceCounter > 0;
+}
+
+void CStereoOVR::releaseLibrary()
+{
+ nlassert(s_DeviceCounter == 0);
+ s_StereoOVRSystem.Release();
+}
+
+} /* namespace NL3D */
+
+/* end of file */
diff --git a/code/snowballs2/bin/snowballs_client_default.cfg b/code/snowballs2/bin/snowballs_client_default.cfg
index ba9178e19..758bd8483 100755
--- a/code/snowballs2/bin/snowballs_client_default.cfg
+++ b/code/snowballs2/bin/snowballs_client_default.cfg
@@ -47,8 +47,8 @@ FpsSmoothing = 64;
OpenGL = 1;
// Resolution of the screen
-ScreenWidth = 800;
-ScreenHeight = 600;
+ScreenWidth = 1280;
+ScreenHeight = 800;
ScreenDepth = 32;
// If 1, run in fullscreen mode, 0 for windowed
@@ -58,6 +58,15 @@ ScreenFull = 0;
StartPoint = { 1840.0, -970.0, 0.0 };
+//////////////////////////////////////////////////////////////////////////////
+// HMD Variables /////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+HMDEnable = 1;
+HMDDeviceId = 0;
+HMDDevice = "Auto";
+
+
//////////////////////////////////////////////////////////////////////////////
// Sound Variables ///////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
diff --git a/code/snowballs2/client/src/camera.cpp b/code/snowballs2/client/src/camera.cpp
index b202fba63..d71ebc134 100644
--- a/code/snowballs2/client/src/camera.cpp
+++ b/code/snowballs2/client/src/camera.cpp
@@ -21,6 +21,7 @@
#include
#include
+#include
#include
#include
#include
@@ -33,6 +34,8 @@
#include
#include
+#include
+
#include "snowballs_client.h"
#include "entities.h"
#include "mouse_listener.h"
@@ -67,12 +70,47 @@ static UInstance Sky = NULL;
static UCloudScape *Clouds = NULL;
+static CStereoOVR *s_StereoHMD = NULL;
+
//
// Functions
//
void initCamera()
{
+ if (ConfigFile->getVar("HMDEnable").asBool())
+ {
+ std::vector devices;
+ CStereoOVR::listDevices(devices);
+ for (std::vector::iterator it(devices.begin()), end(devices.end()); it != end; ++it)
+ {
+ std::stringstream name;
+ name << std::string("[") << (uint32)it->Identifier << "] [" << it->Manufacturer << " - " << it->ProductName << "]";
+ nlinfo("Stereo Device: %s", name.str().c_str());
+ }
+ CStereoDeviceInfo *deviceInfo = NULL;
+ std::string hmdDeviceCfg = ConfigFile->getVar("HMDDevice").asString();
+ if (hmdDeviceCfg == std::string("Auto")
+ && devices.begin() != devices.end())
+ {
+ deviceInfo = &devices[0];
+ }
+ else
+ {
+ uint8 hmdDeviceId = (ConfigFile->getVar("HMDDeviceId").asInt() & 0xFF);
+ for (std::vector::iterator it(devices.begin()), end(devices.end()); it != end; ++it)
+ {
+ std::stringstream name;
+ name << it->Manufacturer << " - " << it->ProductName;
+ if (name.str() == hmdDeviceCfg)
+ deviceInfo = &(*it);
+ if (hmdDeviceId == it->Identifier)
+ break;
+ }
+ }
+ //s_StereoHMD->createDevice(
+ }
+
// Set up directly the camera
Camera = Scene->getCam();
Camera.setTransformMode (UTransformable::DirectMatrix);
@@ -114,6 +152,8 @@ void releaseCamera()
Driver->deleteScene(SkyScene);
Scene->deleteInstance(Snow);
VisualCollisionManager->deleteEntity(CamCollisionEntity);
+
+ CStereoOVR::releaseLibrary();
}
void updateCamera()
diff --git a/code/snowballs2/client/src/snowballs_client.cpp b/code/snowballs2/client/src/snowballs_client.cpp
index 1d7fefd60..e0f044174 100644
--- a/code/snowballs2/client/src/snowballs_client.cpp
+++ b/code/snowballs2/client/src/snowballs_client.cpp
@@ -356,6 +356,7 @@ void initIngame()
//#ifdef NL_OS_WINDOWS
// playMusic(SBCLIENT_MUSIC_WAIT);
//#endif
+ displayLoadingState("Initialize");
// Create a scene
Scene = Driver->createScene(false);
@@ -366,7 +367,6 @@ void initIngame()
CBloomEffect::instance().init(ConfigFile->getVar("OpenGL").asInt() == 1);
CConfiguration::setAndCallback("SquareBloom", cbSquareBloom);
CConfiguration::setAndCallback("DensityBloom", cbDensityBloom);
-
// Init the landscape using the previously created UScene
displayLoadingState("Initialize Landscape");
initLandscape();
@@ -1141,21 +1141,29 @@ sint main(int argc, char **argv)
FILE *f = _tfopen(_T(SBCLIENT_CONFIG_FILE_DEFAULT), _T("r"));
if (!f)
{
- OutputDebugString(" ******************************** \n");
- OutputDebugString(" * CHANGING WORKING DIRECTORY * \n");
- OutputDebugString(" ******************************** \n\n");
- char cwd[256];
- _tgetcwd(cwd, 256);
- tstring workdir(cwd);
- workdir += "\\..\\bin\\";
- _tchdir(workdir.c_str());
- f = _tfopen(_T(SBCLIENT_CONFIG_FILE_DEFAULT), _T("r"));
+ f = _tfopen(_T(SBCLIENT_CONFIG_FILE), _T("r"));
if (!f)
{
OutputDebugString(" ******************************** \n");
- OutputDebugString(" * DEFAULT CONFIG MISSING * \n");
+ OutputDebugString(" * CHANGING WORKING DIRECTORY * \n");
OutputDebugString(" ******************************** \n\n");
- return EXIT_FAILURE;
+ char cwd[256];
+ _tgetcwd(cwd, 256);
+ tstring workdir(cwd);
+ workdir = "R:\\build\\devw_x86\\bin\\Debug\\";
+ _tchdir(workdir.c_str());
+ f = _tfopen(_T(SBCLIENT_CONFIG_FILE_DEFAULT), _T("r"));
+ if (!f)
+ {
+ f = _tfopen(_T(SBCLIENT_CONFIG_FILE), _T("r"));
+ if (!f)
+ {
+ OutputDebugString(" ******************************** \n");
+ OutputDebugString(" * DEFAULT CONFIG MISSING * \n");
+ OutputDebugString(" ******************************** \n\n");
+ return EXIT_FAILURE;
+ }
+ }
}
}
fclose(f);
diff --git a/code/snowballs2/client/src/snowballs_config.h b/code/snowballs2/client/src/snowballs_config.h
index 9565fe4cf..fb304ba68 100644
--- a/code/snowballs2/client/src/snowballs_config.h
+++ b/code/snowballs2/client/src/snowballs_config.h
@@ -75,7 +75,7 @@
# ifndef SNOWBALLS_CONFIG
# define SBCLIENT_CONFIG_FILE "snowballs_client.cfg"
# else
-# define SBCLIENT_CONFIG_FILE SNOWBALLS_CONFIG "client.cfg"
+# define SBCLIENT_CONFIG_FILE SNOWBALLS_CONFIG "snowballs_client.cfg"
# endif
#endif