protected override void OnLoad(EventArgs e) { base.OnLoad(e); initGLObjects(); GL.ClearColor(0.2f, 0.2f, 0.2f, 1.0f); GL.Enable(EnableCap.CullFace); GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.Blend); //initialize the library InitParams initParams = new InitParams() { Flags = InitFlags.None, RequestedMinorVersion = Constants.OVR_MINOR_VERSION, LogCallback = null, UserData = IntPtr.Zero, ConnectionTimeoutMS = 0 }; result = OvrDLL.ovr_Initialize(ref initParams); if (result < 0) { Console.WriteLine("Failed to initialize OVR"); } //create the session result = OvrDLL.ovr_Create(ref session, ref luid); if (result < 0) { Console.WriteLine("Failed to create OVR session"); } //get device description and capabilities hmdDesc = OvrDLL.ovr_GetHmdDesc(session); Console.WriteLine("HMD Type: {0}", hmdDesc.Type); Console.WriteLine("HMD Product Name: {0}", hmdDesc.ProductName); Console.WriteLine("HMD Manufacturer: {0}", hmdDesc.Manufacturer); Console.WriteLine("HMD Serial Number: {0}", hmdDesc.SerialNumber); Console.WriteLine("HMD Resolution {0}x{1}", hmdDesc.Resolution.Width, hmdDesc.Resolution.Height); Console.WriteLine("Version String: {0}", OvrDLL.ovr_GetVersionString()); //get the eye descriptions eyes[0].desc = OvrDLL.ovr_GetRenderDesc(session, EyeType.Left, hmdDesc.LeftDefaultEyeFov); eyes[1].desc = OvrDLL.ovr_GetRenderDesc(session, EyeType.Right, hmdDesc.RightDefaultEyeFov); //get the tracker (the first one) description and then recenter it TrackerDesc trackDesc = OvrDLL.ovr_GetTrackerDesc(session, 0); Console.WriteLine("Tracker 0 description: FOV H: {0} V: {1} Near: {2} Far: {3}", trackDesc.FrustumHFovInRadians, trackDesc.FrustumVFovInRadians, trackDesc.FrustumNearZInMeters, trackDesc.FrustumFarZInMeters); OvrDLL.ovr_RecenterTrackingOrigin(session); Console.WriteLine("Tracker origin recentered"); //create layers layers.AddLayerEyeFov(); // in slot 0 //init each of the eye targets with swap chains/fbo/etc for (int i = 0; i < 2; i++) { initEyeTarget((EyeType)i); } //create the mirror texture MirrorTextureDesc mirrorDesc = new MirrorTextureDesc() { Format = TextureFormat.R8G8B8A8_UNORM_SRGB, Width = 800, Height = 600 }; result = OvrDLL.ovr_CreateMirrorTextureGL(session, ref mirrorDesc, ref mirror); if (result < 0) { Console.WriteLine("Error creating mirror texture"); OvrDLL.ovr_GetLastErrorInfo(ref error); Console.WriteLine("Last Error Info: {0}-{1}", error.result, error.ErrorString); } OvrDLL.ovr_GetMirrorTextureBufferGL(session, mirror, ref myMirrorTexture); Console.WriteLine("OpenGL Mirror texture ID: {0}", myMirrorTexture); }