ovr_sdk
diff LibOVR/Src/Displays/OVR_Display.h @ 0:1b39a1b46319
initial 0.4.4
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 14 Jan 2015 06:51:16 +0200 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/LibOVR/Src/Displays/OVR_Display.h Wed Jan 14 06:51:16 2015 +0200 1.3 @@ -0,0 +1,203 @@ 1.4 +/************************************************************************************ 1.5 + 1.6 +PublicHeader: None 1.7 +Filename : OVR_Display.h 1.8 +Content : Contains platform independent display management 1.9 +Created : May 6, 2014 1.10 +Notes : 1.11 + 1.12 +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. 1.13 + 1.14 +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); 1.15 +you may not use the Oculus VR Rift SDK except in compliance with the License, 1.16 +which is provided at the time of installation or download, or which 1.17 +otherwise accompanies this software in either electronic or hard copy form. 1.18 + 1.19 +You may obtain a copy of the License at 1.20 + 1.21 +http://www.oculusvr.com/licenses/LICENSE-3.2 1.22 + 1.23 +Unless required by applicable law or agreed to in writing, the Oculus VR SDK 1.24 +distributed under the License is distributed on an "AS IS" BASIS, 1.25 +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1.26 +See the License for the specific language governing permissions and 1.27 +limitations under the License. 1.28 + 1.29 +************************************************************************************/ 1.30 + 1.31 +#ifndef OVR_Display_h 1.32 +#define OVR_Display_h 1.33 + 1.34 +#include "../Sensors/OVR_DeviceConstants.h" // Required for HmdTypeEnum 1.35 + 1.36 +#include "../Kernel/OVR_Types.h" 1.37 +#include "../Kernel/OVR_Atomic.h" 1.38 +#include "../Kernel/OVR_RefCount.h" 1.39 +#include "../Kernel/OVR_Array.h" 1.40 +#include "../Kernel/OVR_String.h" 1.41 +#include "../Kernel/OVR_Math.h" 1.42 + 1.43 +namespace OVR { 1.44 + 1.45 + 1.46 +class DisplaySearchHandle : virtual public RefCountBaseV<DisplaySearchHandle> 1.47 +{ 1.48 +public: 1.49 + DisplaySearchHandle() {} 1.50 + 1.51 + virtual ~DisplaySearchHandle() {} 1.52 + 1.53 + void operator= (const DisplaySearchHandle&) {} 1.54 +}; 1.55 + 1.56 +//------------------------------------------------------------------------------------- 1.57 +// ***** Display 1.58 + 1.59 +// Display object describes an Oculus HMD screen in LibOVR, providing information such 1.60 +// as EDID serial number and resolution in platform-independent manner. 1.61 +// 1.62 +// Display is an abstract base class to support OS and driver specific implementations. 1.63 +// It support HMD screen enumeration through GetDisplayCount/GetDisplay static functions. 1.64 +// 1.65 +// Examples of implementations of Display are the following: 1.66 +// Display_Win32_Generic - Compatibly mode implementation that maintains operation on 1.67 +// systems without drivers. 1.68 +// Display_Win32_Driver - Driver-Based display 1.69 +// Display_OSX_Generic - Additional compatibility mode implementation for OS X 1.70 + 1.71 +class Display : public RefCountBase<Display> 1.72 +{ 1.73 +protected: 1.74 + enum MirrorMode 1.75 + { 1.76 + MirrorEnabled = 0, 1.77 + MirrorDisabled = 1 1.78 + }; 1.79 + 1.80 + MirrorMode mirrorMode; 1.81 + 1.82 + Display( 1.83 + HmdTypeEnum deviceTypeGuess, 1.84 +#ifdef OVR_OS_MAC 1.85 + uint32_t displayID, 1.86 +#else 1.87 + const String& displayID, 1.88 +#endif 1.89 + const String& modelName, 1.90 + const String& editSerial, 1.91 + const Sizei& logicalRes, 1.92 + const Sizei& nativeRes, 1.93 + const Vector2i& displayOffset, 1.94 + const uint64_t devNumber, 1.95 + const uint32_t rotation, 1.96 + const bool appExclusive): 1.97 + mirrorMode(MirrorDisabled), 1.98 + DeviceTypeGuess(deviceTypeGuess), 1.99 + DisplayID(displayID), 1.100 + ModelName(modelName), 1.101 + EdidSerialNumber(editSerial), 1.102 + LogicalResolutionInPixels(logicalRes), 1.103 + NativeResolutionInPixels(nativeRes), 1.104 + DesktopDisplayOffset(displayOffset), 1.105 + DeviceNumber(devNumber), 1.106 + Rotation(rotation), 1.107 + ApplicationExclusive(appExclusive) 1.108 + { 1.109 + } 1.110 + 1.111 + void operator = (const Display&) { } // Quiet warning. 1.112 + 1.113 +public: 1.114 + virtual ~Display() { } 1.115 + 1.116 + // ----- Platform specific static Display functionality ----- 1.117 + 1.118 + // Mandatory function that sets up the display environment with 1.119 + // any necessary shimming and function hooks. This should be one 1.120 + // of the very first things your application does when it 1.121 + // initializes LibOVR 1.122 + static bool Initialize(); 1.123 + 1.124 + // Returns a count of the detected displays. These are Rift displays 1.125 + // attached directly to an active display port 1.126 + static int GetDisplayCount( DisplaySearchHandle* handle = NULL, bool extended = true, bool applicationOnly = true, bool extendedEDIDSerials = false ); 1.127 + // Returns a specific index of a display. Displays are sorted in no particular order. 1.128 + static Ptr<Display> GetDisplay( int index = 0, DisplaySearchHandle* handle = NULL ); 1.129 + 1.130 + 1.131 + // Returns true if we are referencing the same display; useful for matching display 1.132 + // objects with the ones already detected. 1.133 + bool MatchDisplay(const Display* other) 1.134 + { 1.135 + // Note this is not checking the DeviceName, which corresponds to which monitor the device is. 1.136 + // This allows matching to match a display that has changed how it is plugged in. 1.137 + return (DisplayID == other->DisplayID) && 1.138 + (EdidSerialNumber == other->EdidSerialNumber) && 1.139 + (NativeResolutionInPixels == other->NativeResolutionInPixels) && 1.140 + (DesktopDisplayOffset == other->DesktopDisplayOffset) && 1.141 + (ApplicationExclusive == other->ApplicationExclusive); 1.142 + } 1.143 + 1.144 + 1.145 + // ----- Device independent instance based Display functionality ----- 1.146 + 1.147 + // Device type guess based on display info. 1.148 + const HmdTypeEnum DeviceTypeGuess; 1.149 +#if defined(OVR_OS_MAC) 1.150 + // CGDirectDisplayID for the rift. 1.151 + const uint32_t DisplayID; 1.152 +#else 1.153 + // A string denoting the display device name so that apps can recognize the monitor 1.154 + const String DisplayID; 1.155 +#endif 1.156 + // A literal string containing the name of the model, i.e. Rift DK2 1.157 + const String ModelName; 1.158 + // Part of the serial number encoded in Edid, used for monitor <-> sensor matching. 1.159 + const String EdidSerialNumber; 1.160 + // Logical resolution is the display resolution in presentation terms. 1.161 + // That is to say, the resolution that represents the orientation the 1.162 + // display is projected to the user. For DK2, while being a portrait display 1.163 + // the display is held in landscape and therefore the logical resolution 1.164 + // is 1920x1080 1.165 + const Sizei LogicalResolutionInPixels; 1.166 + // Native resolution is the resolution reported by the EDID and represents the 1.167 + // exact hardware resolution of the Rift. For example, on DK2 1.168 + // this is 1080x1920 1.169 + // In theory, an OS rotated Rift's native and logical resolutions should match 1.170 + const Sizei NativeResolutionInPixels; 1.171 + // For displays that are attached to the desktop, this return value has meaning. 1.172 + // Otherwise it should always return origin 1.173 + const Vector2i DesktopDisplayOffset; 1.174 + // For Windows machines this value stores the ChildUid used to identify this display 1.175 + const uint64_t DeviceNumber; 1.176 + // Stores the device specific default rotation of the screen 1.177 + // E.g. DK2 is rotated 90 degrees as it is a portrait display 1.178 + const uint32_t Rotation; 1.179 + // Is set if the Display is capable in Application-Only mode 1.180 + const bool ApplicationExclusive; 1.181 + 1.182 + // Functionality for rendering within the window 1.183 + virtual MirrorMode SetMirrorMode( MirrorMode newMode ) = 0; 1.184 + 1.185 + // Functionality for enabling/disabling display 1.186 + virtual bool SetDisplaySleep(bool off) 1.187 + { 1.188 + // Override to implement if supported 1.189 + OVR_UNUSED(off); 1.190 + return false; 1.191 + } 1.192 + 1.193 + // Check if right now the current rendering application should be in compatibility mode 1.194 + static bool InCompatibilityMode( bool displaySearch = true ); 1.195 + 1.196 + // Get/set the mode for all applications 1.197 + static bool GetDriverMode(bool& driverInstalled, bool& compatMode, bool& hideDK1Mode); 1.198 + static bool SetDriverMode(bool compatMode, bool hideDK1Mode); 1.199 + 1.200 + static DisplaySearchHandle* GetDisplaySearchHandle(); 1.201 +}; 1.202 + 1.203 + 1.204 +} // namespace OVR 1.205 + 1.206 +#endif