コード例 #1
0
ファイル: OculusOverlay.cs プロジェクト: santoshna/xenko-1
        public OculusOverlay(IntPtr ovrSession, GraphicsDevice device, int width, int height, int mipLevels, int sampleCount)
        {
            int textureCount;

            this.ovrSession = ovrSession;

            OverlayPtr = OculusOvr.CreateQuadLayerTexturesDx(ovrSession, device.NativeDevice.NativePointer, out textureCount, width, height, mipLevels, sampleCount);
            if (OverlayPtr == null)
            {
                throw new Exception(OculusOvr.GetError());
            }

            textures = new Texture[textureCount];
            for (var i = 0; i < textureCount; i++)
            {
                var ptr = OculusOvr.GetQuadLayerTextureDx(ovrSession, OverlayPtr, OculusOvrHmd.Dx11Texture2DGuid, i);
                if (ptr == IntPtr.Zero)
                {
                    throw new Exception(OculusOvr.GetError());
                }

                textures[i] = new Texture(device);
                textures[i].InitializeFromImpl(new Texture2D(ptr), false);
            }
        }
コード例 #2
0
ファイル: OculusOvrHmd.cs プロジェクト: glepag1/stride
        public override void Enable(GraphicsDevice device, GraphicsDeviceManager graphicsDeviceManager, bool requireMirror, int mirrorWidth, int mirrorHeight)
        {
            graphicsDevice = device;
            long adapterId;

            ovrSession = OculusOvr.CreateSessionDx(out adapterId);
            //Game.GraphicsDeviceManager.RequiredAdapterUid = adapterId.ToString(); //should not be needed

            int texturesCount;

            if (!OculusOvr.CreateTexturesDx(ovrSession, device.NativeDevice.NativePointer, out texturesCount, RenderFrameScaling, requireMirror ? mirrorWidth : 0, requireMirror ? mirrorHeight : 0))
            {
                throw new Exception(OculusOvr.GetError());
            }

            if (requireMirror)
            {
                var mirrorTex = OculusOvr.GetMirrorTexture(ovrSession, Dx11Texture2DGuid);
                MirrorTexture = new Texture(device);
                MirrorTexture.InitializeFromImpl(new Texture2D(mirrorTex), false);
            }

            textures = new Texture[texturesCount];
            for (var i = 0; i < texturesCount; i++)
            {
                var ptr = OculusOvr.GetTextureDx(ovrSession, Dx11Texture2DGuid, i);
                if (ptr == IntPtr.Zero)
                {
                    throw new Exception(OculusOvr.GetError());
                }

                textures[i] = new Texture(device);
                textures[i].InitializeFromImpl(new Texture2D(ptr), false);
            }

            ActualRenderFrameSize = new Size2(textures[0].Width, textures[0].Height);

            leftHandController  = new OculusTouchController(TouchControllerHand.Left);
            rightHandController = new OculusTouchController(TouchControllerHand.Right);
        }