Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef INC_OSX_OculusRoomTiny_h
00024 #define INC_OSX_OculusRoomTiny_h
00025
00026 #import <Cocoa/Cocoa.h>
00027
00028 #import <CoreGraphics/CoreGraphics.h>
00029 #import <CoreGraphics/CGDirectDisplay.h>
00030
00031
00032 #include "OVR.h"
00033 #include "Util/Util_Render_Stereo.h"
00034 #include "../../LibOVR/Src/Kernel/OVR_Timer.h"
00035 #include "RenderTiny_GL_Device.h"
00036
00037 using namespace OVR;
00038 using namespace OVR::RenderTiny;
00039
00040 class OculusRoomTinyApp;
00041
00042 @interface OVRApp : NSApplication
00043
00044 @property (assign) IBOutlet NSWindow* win;
00045 @property (assign) OculusRoomTinyApp* App;
00046
00047 -(void) run;
00048
00049 @end
00050
00051 @interface OVRView : NSOpenGLView <NSWindowDelegate>
00052
00053
00054 @property (assign) OculusRoomTinyApp* App;
00055 @property unsigned long Modifiers;
00056
00057 -(void)ProcessMouse:(NSEvent*)event;
00058 -(void)warpMouseToCenter;
00059
00060 +(CGDirectDisplayID) displayFromScreen:(NSScreen*)s;
00061
00062 @end
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 const Vector3f UpVector(0.0f, 1.0f, 0.0f);
00084 const Vector3f ForwardVector(0.0f, 0.0f, -1.0f);
00085 const Vector3f RightVector(1.0f, 0.0f, 0.0f);
00086
00087
00088 const float YawInitial = 3.141592f;
00089 const float Sensitivity = 1.0f;
00090 const float MoveSpeed = 3.0f;
00091
00092 namespace OSX
00093 {
00094 class RenderDevice : public GL::RenderDevice
00095 {
00096 public:
00097 void* Context;
00098
00099
00100 RenderDevice(const RendererParams& p, void* osview, void* context);
00101
00102 virtual void Shutdown();
00103 virtual void Present();
00104
00105 virtual bool SetFullscreen(DisplayMode fullscreen);
00106
00107
00108 static RenderDevice* CreateDevice(const RendererParams& rp, void* osview);
00109 };
00110 }
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 class OculusRoomTinyApp : public MessageHandler
00128 {
00129 friend class OSX::RenderDevice;
00130 public:
00131 OculusRoomTinyApp(OVRApp* nsapp);
00132 ~OculusRoomTinyApp();
00133
00134
00135 virtual int OnStartup(const char* args);
00136
00137 virtual void OnIdle();
00138
00139
00140 virtual void OnMessage(const Message& msg);
00141
00142
00143 virtual void OnMouseMove(int x, int y, int modifiers);
00144 virtual void OnKey(unsigned vk, bool down);
00145
00146
00147 void Render(const StereoEyeParams& stereo);
00148
00149
00150 int Run();
00151 void Exit();
00152
00153
00154 double GetAppTime() const
00155 {
00156 return (OVR::Timer::GetTicks() - StartupTicks) * (1.0 / (double)OVR::Timer::MksPerSecond);
00157 }
00158 bool IsQuiting() const { return Quit; }
00159
00160 int GetWidth() const { return Width; }
00161 int GetHeight() const { return Height; }
00162
00163 bool SetFullscreen(const RendererParams& rp, int fullscreen);
00164
00165 protected:
00166 bool setupWindow();
00167 void destroyWindow();
00168
00169 NSView* View;
00170 NSWindow* Win;
00171 OVRApp* NsApp;
00172
00173 static OculusRoomTinyApp* pApp;
00174
00175
00176 Ptr<OSX::RenderDevice> pRender;
00177 RendererParams RenderParams;
00178 int Width, Height;
00179
00180 bool Quit;
00181
00182
00183
00184 Ptr<DeviceManager> pManager;
00185 Ptr<SensorDevice> pSensor;
00186 Ptr<HMDDevice> pHMD;
00187 SensorFusion SFusion;
00188 OVR::HMDInfo HMDInfo;
00189
00190
00191 double LastUpdate;
00192 OVR::UInt64 StartupTicks;
00193
00194
00195 Vector3f EyePos;
00196 float EyeYaw;
00197 float EyePitch;
00198 float EyeRoll;
00199 float LastSensorYaw;
00200
00201
00202 UByte MoveForward;
00203 UByte MoveBack;
00204 UByte MoveLeft;
00205 UByte MoveRight;
00206
00207 Matrix4f ViewMat;
00208 RenderTiny::Scene Scene;
00209
00210
00211 StereoConfig SConfig;
00212 PostProcessType PostProcess;
00213
00214
00215 bool ShiftDown;
00216 bool ControlDown;
00217 };
00218
00219
00220 void PopulateRoomScene(Scene* scene, RenderDevice* render);
00221
00222
00223 #endif