예제 #1
0
        public Capture(string leftCamera, string rightCamera, Device d3dDevice)
        {
            DsDevice[] systemCamereas = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);

            foreach(var device in systemCamereas)
            {
                if (device.DevicePath.Equals(leftCamera))
                {
                    m_leftCamera = new Camera(device, d3dDevice);
                }
                if (device.DevicePath.Equals(rightCamera))
                {
                    m_rightCamera = new Camera(device, d3dDevice);
                }
            }
        }
예제 #2
0
        public Renderer(Control _control, Camera left, Camera right, bool _fullscreen)
        {
            fullscreen = _fullscreen;
            m_Control = _control;
            m_leftCamera = left;
            m_rightCamera = right;

            if (m_leftCamera != null)
            {
               // m_leftCamera.FrameComplete += m_leftCamera_FrameComplete;
            }

            if (m_Device == null)
            {
                Direct3DEx _d3d = new Direct3DEx();
                PresentParameters _parameters = new PresentParameters();
                if (fullscreen)
                {
                    _parameters.BackBufferWidth = 1920;// m_Control.Width;
                    _parameters.BackBufferHeight = 1080;// m_Control.Height;
                }
                else
                {
                    _parameters.BackBufferWidth = 1280;// m_Control.Width;
                    _parameters.BackBufferHeight = 800;// m_Control.Height;
                }

                if (fullscreen)
                {
                    _parameters.BackBufferFormat = Format.X8R8G8B8;
                    _parameters.BackBufferCount = 1;
                    _parameters.Multisample = MultisampleType.None;
                    _parameters.SwapEffect = SwapEffect.Flip;
                    //_parameters.PresentationInterval = PresentInterval.Default;
                    _parameters.PresentationInterval = PresentInterval.Immediate;
                    _parameters.Windowed = false;
                    _parameters.DeviceWindowHandle = m_Control.Parent.Handle;
                    _parameters.SwapEffect = SwapEffect.Flip;
                    _parameters.FullScreenRefreshRateInHertz = 0;
                    _parameters.PresentFlags = PresentFlags.None | PresentFlags.DiscardDepthStencil;
                    _parameters.AutoDepthStencilFormat = Format.D24X8;
                    _parameters.EnableAutoDepthStencil = true;
                    m_Device = new Device(_d3d, 0, DeviceType.Hardware, m_Control.Parent.Handle, CreateFlags.Multithreaded | CreateFlags.HardwareVertexProcessing, _parameters);
                }
                else
                {

                    DisplayMode _mode = _d3d.GetAdapterDisplayMode(0);
                    _parameters.BackBufferFormat = _mode.Format;
                    _parameters.BackBufferCount = 1;
                    _parameters.Multisample = MultisampleType.None;
                    _parameters.SwapEffect = SwapEffect.Flip;
                    _parameters.PresentationInterval = PresentInterval.Default;
                    _parameters.Windowed = true;
                    _parameters.DeviceWindowHandle = m_Control.Handle;
                    _parameters.PresentationInterval = PresentInterval.Immediate;
                    _parameters.PresentFlags = PresentFlags.DeviceClip | PresentFlags.Video;
                    m_Device = new DeviceEx(_d3d, 0, DeviceType.Hardware, m_Control.Handle, CreateFlags.Multithreaded | CreateFlags.HardwareVertexProcessing, _parameters);
                }
            }

            m_RenderTarget = m_Device.GetRenderTarget(0);

            leftTex = new Texture(m_Device, 1280, 720, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default);
            //leftTex = Texture.FromFile(m_Device, ".\\Images\\checkerboard.jpg", D3DX.DefaultNonPowerOf2, D3DX.DefaultNonPowerOf2, 1, Usage.Dynamic, Format.A8R8G8B8, Pool.Default, Filter.None, Filter.None, 0);
            //leftTex = Texture.FromFile(m_Device, ".\\Images\\LeftEye.jpg", D3DX.DefaultNonPowerOf2, D3DX.DefaultNonPowerOf2, 1, Usage.RenderTarget, Format.Unknown, Pool.Default, Filter.None, Filter.None, 0);
            SurfaceDescription desc = leftTex.GetLevelDescription(0);
            //leftTex = Texture.FromFile(m_Device, ".\\Images\\CheckerboardLeft.jpg", Usage.RenderTarget, Pool.Default);

            rightTex = new Texture(m_Device, 1280, 720, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default);
            //rightTex = Texture.FromFile(m_Device, ".\\Images\\RightEye.jpg", D3DX.DefaultNonPowerOf2, D3DX.DefaultNonPowerOf2, 1, Usage.RenderTarget, Format.Unknown, Pool.Default, Filter.None, Filter.None, 0);
            //rightTex = Texture.FromFile(m_Device, ".\\Images\\CheckerboardRight.jpg", Usage.RenderTarget, Pool.Default);

            m_font = new SlimDX.Direct3D9.Font(m_Device, new System.Drawing.Font(FontFamily.GenericSansSerif, 24.0f));

            m_distortionEffect = Effect.FromFile(m_Device, "OculusRiftPS.fx", ShaderFlags.None);

            //leftImage = Surface.CreateOffscreenPlain(m_Device, 640, 720, Format.A8R8G8B8, Pool.Default);
            //Surface.FromFile(leftImage, ".\\Images\\checkerboardRedGreen.jpg", Filter.None, 0);

            //rightImage = Surface.CreateOffscreenPlain(m_Device, 640, 720, Format.A8R8G8B8, Pool.Default);
            //Surface.FromFile(rightImage, ".\\Images\\checkerboardRedGreen.jpg", Filter.None, 0);
            //tex = new Texture(m_Device, 1280, 720, 1, Usage.Dynamic, Format.A8R8G8B8, Pool.Default);

            //tex = new Texture(m_Device, 1280, 720, 1, Usage.RenderTarget, Format.R8G8B8, Pool.Default);
        }