Beispiel #1
0
        public VideoPanel()
        {
            var lTuple = D3D9Image.createD3D9Image();

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

                this.sharedResource = lTuple.Item2;

                this.sharedHandle = sharedResource.SharedHandle;
            }

            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;
            }
        }
Beispiel #2
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);
        }