rev |
line source |
nuclear@0
|
1 /************************************************************************************
|
nuclear@0
|
2
|
nuclear@0
|
3 PublicHeader: None
|
nuclear@0
|
4 Filename : OVR_Display.h
|
nuclear@0
|
5 Content : Contains platform independent display management
|
nuclear@0
|
6 Created : May 6, 2014
|
nuclear@0
|
7 Notes :
|
nuclear@0
|
8
|
nuclear@0
|
9 Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
|
nuclear@0
|
10
|
nuclear@0
|
11 Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
|
nuclear@0
|
12 you may not use the Oculus VR Rift SDK except in compliance with the License,
|
nuclear@0
|
13 which is provided at the time of installation or download, or which
|
nuclear@0
|
14 otherwise accompanies this software in either electronic or hard copy form.
|
nuclear@0
|
15
|
nuclear@0
|
16 You may obtain a copy of the License at
|
nuclear@0
|
17
|
nuclear@0
|
18 http://www.oculusvr.com/licenses/LICENSE-3.2
|
nuclear@0
|
19
|
nuclear@0
|
20 Unless required by applicable law or agreed to in writing, the Oculus VR SDK
|
nuclear@0
|
21 distributed under the License is distributed on an "AS IS" BASIS,
|
nuclear@0
|
22 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
nuclear@0
|
23 See the License for the specific language governing permissions and
|
nuclear@0
|
24 limitations under the License.
|
nuclear@0
|
25
|
nuclear@0
|
26 ************************************************************************************/
|
nuclear@0
|
27
|
nuclear@0
|
28 #ifndef OVR_Display_h
|
nuclear@0
|
29 #define OVR_Display_h
|
nuclear@0
|
30
|
nuclear@0
|
31 #include "../Sensors/OVR_DeviceConstants.h" // Required for HmdTypeEnum
|
nuclear@0
|
32
|
nuclear@0
|
33 #include "../Kernel/OVR_Types.h"
|
nuclear@0
|
34 #include "../Kernel/OVR_Atomic.h"
|
nuclear@0
|
35 #include "../Kernel/OVR_RefCount.h"
|
nuclear@0
|
36 #include "../Kernel/OVR_Array.h"
|
nuclear@0
|
37 #include "../Kernel/OVR_String.h"
|
nuclear@0
|
38 #include "../Kernel/OVR_Math.h"
|
nuclear@0
|
39
|
nuclear@0
|
40 namespace OVR {
|
nuclear@0
|
41
|
nuclear@0
|
42
|
nuclear@0
|
43 class DisplaySearchHandle : virtual public RefCountBaseV<DisplaySearchHandle>
|
nuclear@0
|
44 {
|
nuclear@0
|
45 public:
|
nuclear@0
|
46 DisplaySearchHandle() {}
|
nuclear@0
|
47
|
nuclear@0
|
48 virtual ~DisplaySearchHandle() {}
|
nuclear@0
|
49
|
nuclear@0
|
50 void operator= (const DisplaySearchHandle&) {}
|
nuclear@0
|
51 };
|
nuclear@0
|
52
|
nuclear@0
|
53 //-------------------------------------------------------------------------------------
|
nuclear@0
|
54 // ***** Display
|
nuclear@0
|
55
|
nuclear@0
|
56 // Display object describes an Oculus HMD screen in LibOVR, providing information such
|
nuclear@0
|
57 // as EDID serial number and resolution in platform-independent manner.
|
nuclear@0
|
58 //
|
nuclear@0
|
59 // Display is an abstract base class to support OS and driver specific implementations.
|
nuclear@0
|
60 // It support HMD screen enumeration through GetDisplayCount/GetDisplay static functions.
|
nuclear@0
|
61 //
|
nuclear@0
|
62 // Examples of implementations of Display are the following:
|
nuclear@0
|
63 // Display_Win32_Generic - Compatibly mode implementation that maintains operation on
|
nuclear@0
|
64 // systems without drivers.
|
nuclear@0
|
65 // Display_Win32_Driver - Driver-Based display
|
nuclear@0
|
66 // Display_OSX_Generic - Additional compatibility mode implementation for OS X
|
nuclear@0
|
67
|
nuclear@0
|
68 class Display : public RefCountBase<Display>
|
nuclear@0
|
69 {
|
nuclear@0
|
70 protected:
|
nuclear@0
|
71 enum MirrorMode
|
nuclear@0
|
72 {
|
nuclear@0
|
73 MirrorEnabled = 0,
|
nuclear@0
|
74 MirrorDisabled = 1
|
nuclear@0
|
75 };
|
nuclear@0
|
76
|
nuclear@0
|
77 MirrorMode mirrorMode;
|
nuclear@0
|
78
|
nuclear@0
|
79 Display(
|
nuclear@0
|
80 HmdTypeEnum deviceTypeGuess,
|
nuclear@0
|
81 #ifdef OVR_OS_MAC
|
nuclear@0
|
82 uint32_t displayID,
|
nuclear@0
|
83 #else
|
nuclear@0
|
84 const String& displayID,
|
nuclear@0
|
85 #endif
|
nuclear@0
|
86 const String& modelName,
|
nuclear@0
|
87 const String& editSerial,
|
nuclear@0
|
88 const Sizei& logicalRes,
|
nuclear@0
|
89 const Sizei& nativeRes,
|
nuclear@0
|
90 const Vector2i& displayOffset,
|
nuclear@0
|
91 const uint64_t devNumber,
|
nuclear@0
|
92 const uint32_t rotation,
|
nuclear@0
|
93 const bool appExclusive):
|
nuclear@0
|
94 mirrorMode(MirrorDisabled),
|
nuclear@0
|
95 DeviceTypeGuess(deviceTypeGuess),
|
nuclear@0
|
96 DisplayID(displayID),
|
nuclear@0
|
97 ModelName(modelName),
|
nuclear@0
|
98 EdidSerialNumber(editSerial),
|
nuclear@0
|
99 LogicalResolutionInPixels(logicalRes),
|
nuclear@0
|
100 NativeResolutionInPixels(nativeRes),
|
nuclear@0
|
101 DesktopDisplayOffset(displayOffset),
|
nuclear@0
|
102 DeviceNumber(devNumber),
|
nuclear@0
|
103 Rotation(rotation),
|
nuclear@0
|
104 ApplicationExclusive(appExclusive)
|
nuclear@0
|
105 {
|
nuclear@0
|
106 }
|
nuclear@0
|
107
|
nuclear@0
|
108 void operator = (const Display&) { } // Quiet warning.
|
nuclear@0
|
109
|
nuclear@0
|
110 public:
|
nuclear@0
|
111 virtual ~Display() { }
|
nuclear@0
|
112
|
nuclear@0
|
113 // ----- Platform specific static Display functionality -----
|
nuclear@0
|
114
|
nuclear@0
|
115 // Mandatory function that sets up the display environment with
|
nuclear@0
|
116 // any necessary shimming and function hooks. This should be one
|
nuclear@0
|
117 // of the very first things your application does when it
|
nuclear@0
|
118 // initializes LibOVR
|
nuclear@0
|
119 static bool Initialize();
|
nuclear@0
|
120
|
nuclear@0
|
121 // Returns a count of the detected displays. These are Rift displays
|
nuclear@0
|
122 // attached directly to an active display port
|
nuclear@0
|
123 static int GetDisplayCount( DisplaySearchHandle* handle = NULL, bool extended = true, bool applicationOnly = true, bool extendedEDIDSerials = false );
|
nuclear@0
|
124 // Returns a specific index of a display. Displays are sorted in no particular order.
|
nuclear@0
|
125 static Ptr<Display> GetDisplay( int index = 0, DisplaySearchHandle* handle = NULL );
|
nuclear@0
|
126
|
nuclear@0
|
127
|
nuclear@0
|
128 // Returns true if we are referencing the same display; useful for matching display
|
nuclear@0
|
129 // objects with the ones already detected.
|
nuclear@0
|
130 bool MatchDisplay(const Display* other)
|
nuclear@0
|
131 {
|
nuclear@0
|
132 // Note this is not checking the DeviceName, which corresponds to which monitor the device is.
|
nuclear@0
|
133 // This allows matching to match a display that has changed how it is plugged in.
|
nuclear@0
|
134 return (DisplayID == other->DisplayID) &&
|
nuclear@0
|
135 (EdidSerialNumber == other->EdidSerialNumber) &&
|
nuclear@0
|
136 (NativeResolutionInPixels == other->NativeResolutionInPixels) &&
|
nuclear@0
|
137 (DesktopDisplayOffset == other->DesktopDisplayOffset) &&
|
nuclear@0
|
138 (ApplicationExclusive == other->ApplicationExclusive);
|
nuclear@0
|
139 }
|
nuclear@0
|
140
|
nuclear@0
|
141
|
nuclear@0
|
142 // ----- Device independent instance based Display functionality -----
|
nuclear@0
|
143
|
nuclear@0
|
144 // Device type guess based on display info.
|
nuclear@0
|
145 const HmdTypeEnum DeviceTypeGuess;
|
nuclear@0
|
146 #if defined(OVR_OS_MAC)
|
nuclear@0
|
147 // CGDirectDisplayID for the rift.
|
nuclear@0
|
148 const uint32_t DisplayID;
|
nuclear@0
|
149 #else
|
nuclear@0
|
150 // A string denoting the display device name so that apps can recognize the monitor
|
nuclear@0
|
151 const String DisplayID;
|
nuclear@0
|
152 #endif
|
nuclear@0
|
153 // A literal string containing the name of the model, i.e. Rift DK2
|
nuclear@0
|
154 const String ModelName;
|
nuclear@0
|
155 // Part of the serial number encoded in Edid, used for monitor <-> sensor matching.
|
nuclear@0
|
156 const String EdidSerialNumber;
|
nuclear@0
|
157 // Logical resolution is the display resolution in presentation terms.
|
nuclear@0
|
158 // That is to say, the resolution that represents the orientation the
|
nuclear@0
|
159 // display is projected to the user. For DK2, while being a portrait display
|
nuclear@0
|
160 // the display is held in landscape and therefore the logical resolution
|
nuclear@0
|
161 // is 1920x1080
|
nuclear@0
|
162 const Sizei LogicalResolutionInPixels;
|
nuclear@0
|
163 // Native resolution is the resolution reported by the EDID and represents the
|
nuclear@0
|
164 // exact hardware resolution of the Rift. For example, on DK2
|
nuclear@0
|
165 // this is 1080x1920
|
nuclear@0
|
166 // In theory, an OS rotated Rift's native and logical resolutions should match
|
nuclear@0
|
167 const Sizei NativeResolutionInPixels;
|
nuclear@0
|
168 // For displays that are attached to the desktop, this return value has meaning.
|
nuclear@0
|
169 // Otherwise it should always return origin
|
nuclear@0
|
170 const Vector2i DesktopDisplayOffset;
|
nuclear@0
|
171 // For Windows machines this value stores the ChildUid used to identify this display
|
nuclear@0
|
172 const uint64_t DeviceNumber;
|
nuclear@0
|
173 // Stores the device specific default rotation of the screen
|
nuclear@0
|
174 // E.g. DK2 is rotated 90 degrees as it is a portrait display
|
nuclear@0
|
175 const uint32_t Rotation;
|
nuclear@0
|
176 // Is set if the Display is capable in Application-Only mode
|
nuclear@0
|
177 const bool ApplicationExclusive;
|
nuclear@0
|
178
|
nuclear@0
|
179 // Functionality for rendering within the window
|
nuclear@0
|
180 virtual MirrorMode SetMirrorMode( MirrorMode newMode ) = 0;
|
nuclear@0
|
181
|
nuclear@0
|
182 // Functionality for enabling/disabling display
|
nuclear@0
|
183 virtual bool SetDisplaySleep(bool off)
|
nuclear@0
|
184 {
|
nuclear@0
|
185 // Override to implement if supported
|
nuclear@0
|
186 OVR_UNUSED(off);
|
nuclear@0
|
187 return false;
|
nuclear@0
|
188 }
|
nuclear@0
|
189
|
nuclear@0
|
190 // Check if right now the current rendering application should be in compatibility mode
|
nuclear@0
|
191 static bool InCompatibilityMode( bool displaySearch = true );
|
nuclear@0
|
192
|
nuclear@0
|
193 // Get/set the mode for all applications
|
nuclear@0
|
194 static bool GetDriverMode(bool& driverInstalled, bool& compatMode, bool& hideDK1Mode);
|
nuclear@0
|
195 static bool SetDriverMode(bool compatMode, bool hideDK1Mode);
|
nuclear@0
|
196
|
nuclear@0
|
197 static DisplaySearchHandle* GetDisplaySearchHandle();
|
nuclear@0
|
198 };
|
nuclear@0
|
199
|
nuclear@0
|
200
|
nuclear@0
|
201 } // namespace OVR
|
nuclear@0
|
202
|
nuclear@0
|
203 #endif
|