Пример #1
0
        // the following functions should be called in order
        public int Init(GraphicsDevice gd)
        {
            graphicsDevice = gd;

            IntPtr dxDevice, dxContext;

            graphicsDevice.GetNativeDxDeviceAndContext(out dxDevice, out dxContext);

            int result;

            if ((result = NativeRift.Init(dxDevice, dxContext)) < 0)
            {
                return(result);
            }

            HmdInfo = NativeRift.GetHmdInfo();

            FovPort fovLeft  = HmdInfo.DefaultFovLeft;
            FovPort fovRight = HmdInfo.DefaultFovRight;

            Point recommendTexResLeft  = Point.Zero;
            Point recommendTexResRight = Point.Zero;

            NativeRift.GetRecommendedRenderTargetRes(fovLeft, fovRight, 1,
                                                     ref recommendTexResLeft, ref recommendTexResRight);

            RenderTargetRes[0] = recommendTexResLeft;
            RenderTargetRes[1] = recommendTexResRight;

            if ((result = NativeRift.CreateDXSwapChains(recommendTexResLeft, recommendTexResRight, fovLeft, fovRight)) < 0)
            {
                return(result);
            }

            for (int eye = 0; eye < 2; eye++)
            {
                ProjectionMatrix[eye] = NativeRift.GetProjectionMatrix(eye, 0.1f, 1000, 0);
            }

            Initialized = true;

            return(0);
        }
Пример #2
0
        // the following functions should be called in order
        public int Init(GraphicsDevice gd)
        {
            graphicsDevice = gd;

            IntPtr dxDevice, dxContext;

            graphicsDevice.GetNativeDxDeviceAndContext(out dxDevice, out dxContext);

            int result;

            if ((result = NativeRift.Init(dxDevice, dxContext)) < 0)
            {
                return(result);
            }

            HmdInfo = NativeRift.GetHmdInfo();

            FovPort fovLeft  = HmdInfo.DefaultFovLeft;
            FovPort fovRight = HmdInfo.DefaultFovRight;

            Point recommendTexResLeft  = Point.Zero;
            Point recommendTexResRight = Point.Zero;

            NativeRift.GetRecommendedRenderTargetRes(fovLeft, fovRight, 1, ref recommendTexResLeft, ref recommendTexResRight);

            RenderTargetRes[0] = recommendTexResLeft;
            RenderTargetRes[1] = recommendTexResRight;

            if ((result = NativeRift.CreateDXSwapChains(recommendTexResLeft, recommendTexResRight, fovLeft, fovRight)) < 0)
            {
                return(result);
            }


            /*None = 0x00,
             *
             * /// <summary>
             * /// Enable if using left-handed transformations in your application.
             * /// </summary>
             * LeftHanded = 0x01,
             *
             * /// <summary>
             * /// After the projection transform is applied, far values stored in the depth buffer will be less than closer depth values.
             * /// NOTE: Enable only if the application is using a floating-point depth buffer for proper precision.
             * /// </summary>
             * FarLessThanNear = 0x02,
             *
             * /// <summary>
             * /// When this flag is used, the zfar value pushed into ovrMatrix4f_Projection() will be ignored
             * /// NOTE: Enable only if ovrProjection_FarLessThanNear is also enabled where the far clipping plane will be pushed to infinity.
             * /// </summary>
             * FarClipAtInfinity = 0x04,
             *
             * /// <summary>
             * /// Enable if the application is rendering with OpenGL and expects a projection matrix with a clipping range of (-w to w).
             * /// Ignore this flag if your application already handles the conversion from D3D range (0 to w) to OpenGL.
             * /// </summary>
             * ClipRangeOpenGL = 0x08*/


            for (int eye = 0; eye < 2; eye++)
            {
                ProjectionMatrix[eye] = NativeRift.GetProjectionMatrix(eye, 0.1f, 1000, 0x00);
            }

            return(0);
        }