ovr_sdk

view LibOVR/Src/Displays/OVR_Display.h @ 3:f12a8f74fe1f

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