Beispiel #1
0
        private bool init()
        {
            bool lresult = false;

            do
            {
                // Free the old surface
                if (this.surface != null)
                {
                    this.surface.Dispose();
                    this.surface = null;
                }

                using (var device = CreateDevice(Interop.NativeMethods.GetDesktopWindow()))
                {
                    surface = GetSharedSurface(device);

                    Lock();

                    this.SetBackBuffer(D3DResourceType.IDirect3DSurface9, this.surface.NativeInterface);

                    Unlock();

                    lresult = true;
                }
            } while (false);

            return(lresult);
        }
Beispiel #2
0
        public EVRDisplay()
        {
            var lTuple = D3D9Image.createD3D9Image();

            if (lTuple != null)
            {
                this.imageSource = lTuple.Item1;

                this.surface = lTuple.Item2;
            }

            if (this.imageSource != null)
            {
                var image = new System.Windows.Controls.Image();
                image.Stretch = System.Windows.Media.Stretch.Uniform;
                image.Source  = this.imageSource;
                this.AddChild(image);

                // To greatly reduce flickering we're only going to AddDirtyRect
                // when WPF is rendering.
                System.Windows.Media.CompositionTarget.Rendering += this.CompositionTargetRendering;
            }
        }