oculus1

view libovr/Src/osx/OVR_OSX_HMDDevice.h @ 29:9a973ef0e2a3

fixed the performance issue under MacOSX by replacing glutSolidTeapot (which uses glEvalMesh) with my own teapot generator.
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 27 Oct 2013 06:31:18 +0200
parents
children
line source
1 /************************************************************************************
3 Filename : OVR_OSX_HMDDevice.h
4 Content : OSX HMDDevice implementation
5 Created : September 21, 2012
6 Authors : Michael Antonov
8 Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
10 Use of this software is subject to the terms of the Oculus license
11 agreement provided at the time of installation or download, or which
12 otherwise accompanies this software in either electronic or hard copy form.
14 *************************************************************************************/
16 #ifndef OVR_OSX_HMDDevice_h
17 #define OVR_OSX_HMDDevice_h
19 #include "OVR_DeviceImpl.h"
20 #include <Kernel/OVR_String.h>
21 #include "OVR_Profile.h"
23 namespace OVR { namespace OSX {
25 class HMDDevice;
28 //-------------------------------------------------------------------------------------
30 // HMDDeviceFactory enumerates attached Oculus HMD devices.
31 //
32 // This is currently done by matching monitor device strings.
34 class HMDDeviceFactory : public DeviceFactory
35 {
36 public:
37 static HMDDeviceFactory Instance;
39 // Enumerates devices, creating and destroying relevant objects in manager.
40 virtual void EnumerateDevices(EnumerateVisitor& visitor);
42 protected:
43 DeviceManager* getManager() const { return (DeviceManager*) pManager; }
44 };
47 class HMDDeviceCreateDesc : public DeviceCreateDesc
48 {
49 friend class HMDDevice;
51 protected:
52 enum
53 {
54 Contents_Screen = 1,
55 Contents_Distortion = 2,
56 Contents_7Inch = 4,
57 };
59 public:
61 HMDDeviceCreateDesc(DeviceFactory* factory,
62 UInt32 vendor, UInt32 product, const String& displayDeviceName, long dispId);
63 HMDDeviceCreateDesc(const HMDDeviceCreateDesc& other);
65 virtual DeviceCreateDesc* Clone() const
66 {
67 return new HMDDeviceCreateDesc(*this);
68 }
70 virtual DeviceBase* NewDeviceInstance();
72 virtual MatchResult MatchDevice(const DeviceCreateDesc& other,
73 DeviceCreateDesc**) const;
75 virtual bool UpdateMatchedCandidate(const DeviceCreateDesc&, bool* newDeviceFlag = NULL);
77 virtual bool GetDeviceInfo(DeviceInfo* info) const;
79 // Requests the currently used default profile. This profile affects the
80 // settings reported by HMDInfo.
81 Profile* GetProfileAddRef() const;
83 ProfileType GetProfileType() const
84 {
85 return (HResolution >= 1920) ? Profile_RiftDKHD : Profile_RiftDK1;
86 }
88 void SetScreenParameters(int x, int y, unsigned hres, unsigned vres, float hsize, float vsize)
89 {
90 DesktopX = x;
91 DesktopY = y;
92 HResolution = hres;
93 VResolution = vres;
94 HScreenSize = hsize;
95 VScreenSize = vsize;
96 Contents |= Contents_Screen;
97 }
99 void SetDistortion(const float* dks)
100 {
101 for (int i = 0; i < 4; i++)
102 DistortionK[i] = dks[i];
103 Contents |= Contents_Distortion;
104 }
106 void Set7Inch() { Contents |= Contents_7Inch; }
108 bool Is7Inch() const;
110 protected:
111 String DeviceId;
112 String DisplayDeviceName;
113 int DesktopX, DesktopY;
114 unsigned Contents;
115 unsigned HResolution, VResolution;
116 float HScreenSize, VScreenSize;
117 long DisplayId;
118 float DistortionK[4];
119 };
122 //-------------------------------------------------------------------------------------
124 // HMDDevice represents an Oculus HMD device unit. An instance of this class
125 // is typically created from the DeviceManager.
126 // After HMD device is created, we its sensor data can be obtained by
127 // first creating a Sensor object and then wrappig it in SensorFusion.
129 class HMDDevice : public DeviceImpl<OVR::HMDDevice>
130 {
131 public:
132 HMDDevice(HMDDeviceCreateDesc* createDesc);
133 ~HMDDevice();
135 virtual bool Initialize(DeviceBase* parent);
136 virtual void Shutdown();
139 // Requests the currently used default profile. This profile affects the
140 // settings reported by HMDInfo.
141 virtual Profile* GetProfile() const;
142 virtual const char* GetProfileName() const;
143 virtual bool SetProfileName(const char* name);
145 // Query associated sensor.
146 virtual OVR::SensorDevice* GetSensor();
148 protected:
149 HMDDeviceCreateDesc* getDesc() const { return (HMDDeviceCreateDesc*)pCreateDesc.GetPtr(); }
151 // User name for the profile used with this device.
152 String ProfileName;
153 mutable Ptr<Profile> pCachedProfile;
154 };
157 }} // namespace OVR::OSX
159 #endif // OVR_OSX_HMDDevice_h