--- /dev/null
+#include "oculusriftdevice.h"
+#include "oculusriftdevice_private.h"
+
+using namespace std;
+
+namespace Msp {
+namespace VR {
+
+OculusRiftDevice::OculusRiftDevice():
+ priv(new Private)
+{
+ static OVR::System system(OVR::Log::ConfigureDefaultLog(OVR::LogMask_Debug));
+
+ priv->ovr_manager = OVR::DeviceManager::Create();
+ priv->ovr_hmd = priv->ovr_manager->EnumerateDevices<OVR::HMDDevice>().CreateDevice();
+ if(!priv->ovr_hmd)
+ {
+ delete priv;
+ throw runtime_error("rift hmd not found");
+ }
+}
+
+OculusRiftDevice::~OculusRiftDevice()
+{
+ delete priv;
+}
+
+OculusRiftCamera *OculusRiftDevice::create_camera(const GL::Camera &bc) const
+{
+ return new OculusRiftCamera(*this, bc);
+}
+
+OculusRiftCombiner *OculusRiftDevice::create_combiner() const
+{
+ OculusRiftCombiner *combiner = new OculusRiftCombiner;
+
+ OVR::HMDInfo info;
+ if(!priv->ovr_hmd->GetDeviceInfo(&info))
+ {
+ combiner->set_view_distance(info.EyeToScreenDistance/info.HScreenSize);
+ combiner->set_lens_separation(info.LensSeparationDistance/info.HScreenSize);
+ combiner->set_distortion(info.DistortionK[0], info.DistortionK[1], info.DistortionK[2], info.DistortionK[3]);
+ combiner->set_red_aberration(info.ChromaAbCorrection[0], info.ChromaAbCorrection[1]);
+ combiner->set_blue_aberration(info.ChromaAbCorrection[2], info.ChromaAbCorrection[3]);
+ }
+
+ return combiner;
+}
+
+} // namespace VR
+} // namespace Msp