Inheritance: System.Windows.Media.ImageSource, MS.Internal.IAppDomainShutdownListener
示例#1
1
        public D3DImageSource(int adapterId)
        {
            this._renderLock = new object();
            this._isVistaOrBetter = Utilities.IsVistaOrBetter();
            this._imageSource = new D3DImage();
            this._imageSource.IsFrontBufferAvailableChanged += ImageSource_IsFrontBufferAvailableChanged;

            this.InitializeD3D();

            this._hiddenWindow = new Form();
            this._hwnd = this._hiddenWindow.Handle;
        }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 5 "..\..\..\CanvasWindow.xaml"
                ((LogoScriptIDE.CanvasWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);

            #line default
            #line hidden

            #line 5 "..\..\..\CanvasWindow.xaml"
                ((LogoScriptIDE.CanvasWindow)(target)).Closing += new System.ComponentModel.CancelEventHandler(this.Window_Closing);

            #line default
            #line hidden
                return;

            case 2:
                this.ui_layout = ((System.Windows.Controls.Canvas)(target));
                return;

            case 3:
                this.imgelt = ((System.Windows.Controls.Image)(target));
                return;

            case 4:
                this.d3dimg = ((System.Windows.Interop.D3DImage)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#3
0
        private static void IsFrontBufferAvailablePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Debug.Assert(e.OldValue != e.NewValue);

            bool isFrontBufferAvailable = (bool)e.NewValue;
            D3DImage img = (D3DImage)d;
            
            if (!isFrontBufferAvailable)
            {
                //
                // This isn't a true "ref" to their surface, so we don't need to do this,
                // but if the user clones this D3DImage afterwards we don't want to
                // have a pontentially garbage pointer being copied
                //
                // We are not Detach()-ing from or releasing _pInteropDeviceBitmap because 
                // if we did, we would never get a notification when the front buffer became 
                // available again.
                //
                if (!img._isSoftwareFallbackEnabled)
                {
                    // If software fallback is enabled, we keep this pointer around to make sure SetBackBuffer with
                    // the same surface pointer is still a no-op. The user is responsible for calling SetBackBuffer 
                    // again (possibly with a null value) to force the release of this pointer.
                    img._pUserSurfaceUnsafe = IntPtr.Zero;
                }
            }
        
            if (img._isFrontBufferAvailableChangedHandlers != null)
            {
                img._isFrontBufferAvailableChangedHandlers(img, e);
            }
        }
示例#4
0
        /// <summary>
        /// Creates a new instance of <see cref="SharpDXElement"/> class.
        /// Initializes the D3D9 runtime.
        /// </summary>
        public SharpDXElement()
        {
            image = new D3DImage();

            var presentparams = new PresentParameters
                {
                    Windowed = true,
                    SwapEffect = SwapEffect.Discard,
                    DeviceWindowHandle = GetDesktopWindow(),
                    PresentationInterval = PresentInterval.Default
                };

            direct3D = new Direct3DEx();

            device9 = new DeviceEx(direct3D,
                                   0,
                                   DeviceType.Hardware,
                                   IntPtr.Zero,
                                   CreateFlags.HardwareVertexProcessing | CreateFlags.Multithreaded | CreateFlags.FpuPreserve,
                                   presentparams);

            resizeDelayTimer = new DispatcherTimer(DispatcherPriority.Normal);
            resizeDelayTimer.Interval = SendResizeDelay;
            resizeDelayTimer.Tick += HandleResizeDelayTimerTick;

            SizeChanged += HandleSizeChanged;
            Unloaded += HandleUnloaded;
        }
示例#5
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;
            }
        }
示例#6
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.myWindow = ((FluidsWPF.MainWindow)(target));

            #line 5 "..\..\..\MainWindow.xaml"
                this.myWindow.Loaded += new System.Windows.RoutedEventHandler(this.myWindow_Loaded);

            #line default
            #line hidden

            #line 5 "..\..\..\MainWindow.xaml"
                this.myWindow.KeyDown += new System.Windows.Input.KeyEventHandler(this.myWindow_KeyDown);

            #line default
            #line hidden

            #line 5 "..\..\..\MainWindow.xaml"
                this.myWindow.Closing += new System.ComponentModel.CancelEventHandler(this.myWindow_Closing);

            #line default
            #line hidden
                return;

            case 2:
                this.infoLog = ((System.Windows.Controls.RichTextBox)(target));
                return;

            case 3:
                this.realFPS = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 4:
                this.deviceName = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 5:
                this.grid = ((System.Windows.Controls.Grid)(target));
                return;

            case 6:
                this.output = ((System.Windows.Controls.Image)(target));

            #line 27 "..\..\..\MainWindow.xaml"
                this.output.MouseMove += new System.Windows.Input.MouseEventHandler(this.output_MouseMove);

            #line default
            #line hidden
                return;

            case 7:
                this.d3dimage = ((System.Windows.Interop.D3DImage)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#7
0
        private void CloneCommon(Freezable sourceFreezable)
        {           
            D3DImage source = (D3DImage)sourceFreezable;

            _dpiX = source._dpiX;
            _dpiY = source._dpiY;
            
            Lock();
            // If we've lost the front buffer, _pUserSurface unsafe will be null
            SetBackBuffer(D3DResourceType.IDirect3DSurface9, source._pUserSurfaceUnsafe);
            Unlock();
        }
        public DrawingSurface()
        {
            _d3DImage = new D3DImage();

            _image = new Image { Source = _d3DImage, Stretch = Stretch.None };
            AddChild(_image);

            _d3DImage.IsFrontBufferAvailableChanged += OnD3DImageIsFrontBufferAvailableChanged;

            Loaded += OnLoaded;
            Unloaded += OnUnloaded;
        }
示例#9
0
        //protected bool CanRender { get { return mBackBuffer != IntPtr.Zero; } }
        public MainWindow()
        {
            mRender = Render.Direct3D.RenderFactory.CreateRender(Render.Direct3D.RenderType.Direct3D11);
            mRender.BackgroundColor = Colors.BlueViolet;

            mD3DImage = new D3DImage();
            mD3DImage.IsFrontBufferAvailableChanged += OnIsFrontBufferAvailableChanged;

            // Do this before initializing components to make the resouce available to XAML
            Resources["D3DImage"] = new ImageBrush(mD3DImage);

            InitializeComponent();
        }
示例#10
0
        public MainWindow()
        {
            RenderImage = new D3DImage();
            RenderImage.IsFrontBufferAvailableChanged
                += new DependencyPropertyChangedEventHandler(OnIsFrontBufferAvailableChanged);

            Resources["RenderSurface"] = new ImageBrush(RenderImage);

            string cmdLine = "--media=\"c:\\home\\proj\\rview\\media\\\"";
            Rush.RushInit(cmdLine);

            BeginRenderingScene();

            InitializeComponent();
        }
        public Window1()
        {
            // create a D3DImage to host the scene and
            // monitor it for changes in front buffer availability
            _di = new D3DImage();
            _di.IsFrontBufferAvailableChanged
                += new DependencyPropertyChangedEventHandler(OnIsFrontBufferAvailableChanged);

            // make a brush of the scene available as a resource on the window
            Resources["RotatingTriangleScene"] = new ImageBrush(_di);

            // begin rendering the custom D3D scene into the D3DImage
            BeginRenderingScene();

            // parse the XAML
            InitializeComponent();
        }
示例#12
0
        public Window1()
        {
            // parse the XAML
            InitializeComponent();

            // Create a D3DImage to host the scene and
            // monitor it for changes in front buffer availability
            d3DImage = new D3DImage();
            d3DImage.IsFrontBufferAvailableChanged += OnIsFrontBufferAvailableChanged;

            // begin rendering the custom D3D scene into the D3DImage
            InitRenderingScene();
            //ImageBrush imageBrush = new ImageBrush(d3dImage);
            //ImageSource imageSource = d3dImage;
            directXImage.Source = d3DImage;
            //Background = new ImageBrush(d3dImage);
            //Foreground = new ImageBrush(d3dImage);
            //directXImage.OpacityMask = imageBrush.ImageSource;
            //directXImage2.Source = imageSource;
            //mainGrid.Background = new ImageBrush(d3dImage);
        }
示例#13
0
        /// <summary>
        /// Creates a new instance of <see cref="SharpDXElement"/> class.
        /// Initializes the D3D9 runtime.
        /// </summary>
        public SharpDXElement()
        {
            image = new D3DImage();

            var presentparams = new PresentParameters
                {
                    Windowed = true,
                    SwapEffect = SwapEffect.Discard,
                    DeviceWindowHandle = GetDesktopWindow(),
                    PresentationInterval = PresentInterval.Default
                };

            direct3D = new Direct3DEx();

            device9 = new DeviceEx(direct3D,
                                   0,
                                   DeviceType.Hardware,
                                   IntPtr.Zero,
                                   CreateFlags.HardwareVertexProcessing | CreateFlags.Multithreaded | CreateFlags.FpuPreserve,
                                   presentparams);

            Unloaded += HandleUnloaded;
        }
示例#14
0
        bool CreateRenderTarget()
        {
            DestroyRenderTarget();

            if( RendererWorld.Instance == null )
                return false;

            Vec2I textureSize = GetDemandTextureSize();
            if( textureSize.X < 1 || textureSize.Y < 1 )
                return false;

            string textureName = TextureManager.Instance.GetUniqueName( "WPFRenderTexture" );

            int hardwareFSAA = 0;
            if( !RendererWorld.InitializationOptions.AllowSceneMRTRendering )
            {
                if( !int.TryParse( RendererWorld.InitializationOptions.FullSceneAntialiasing, out hardwareFSAA ) )
                    hardwareFSAA = 0;
            }

            texture = TextureManager.Instance.Create( textureName, Texture.Type.Type2D, textureSize,
                1, 0, Engine.Renderer.PixelFormat.R8G8B8, Texture.Usage.RenderTarget, false, hardwareFSAA );

            if( texture == null )
                return false;

            currentTextureSize = textureSize;

            renderTexture = texture.GetBuffer().GetRenderTarget();
            renderTexture.AutoUpdate = false;
            renderTexture.AllowAdditionalMRTs = true;

            camera = SceneManager.Instance.CreateCamera(
                SceneManager.Instance.GetUniqueCameraName( "UserControl" ) );
            camera.Purpose = Camera.Purposes.MainCamera;

            //update camera settings
            camera.NearClipDistance = cameraNearFarClipDistance.Minimum;
            camera.FarClipDistance = cameraNearFarClipDistance.Maximum;
            camera.AspectRatio = (float)texture.Size.X / (float)texture.Size.Y;
            camera.FixedUp = cameraFixedUp;
            camera.Position = cameraPosition;
            camera.Direction = cameraDirection;
            camera.Fov = cameraFov;
            camera.ProjectionType = cameraProjectionType;
            camera.OrthoWindowHeight = cameraOrthoWindowHeight;

            viewport = renderTexture.AddViewport( camera );

            //Initialize HDR compositor for HDR render technique
            if( EngineApp.RenderTechnique == "HDR" )
            {
                viewport.AddCompositor( "HDR", 0 );
                viewport.SetCompositorEnabled( "HDR", true );
            }

            //Initialize Fast Approximate Antialiasing (FXAA)
            {
                bool useMRT = RendererWorld.InitializationOptions.AllowSceneMRTRendering;
                string fsaa = RendererWorld.InitializationOptions.FullSceneAntialiasing;
                if( ( useMRT && ( fsaa == "" || fsaa == "RecommendedSetting" ) && IsActivateFXAAByDefault() ) ||
                    fsaa == "FXAA" )
                {
                    if( RenderSystem.Instance.HasShaderModel3() )
                        InitializeFXAACompositor();
                }
            }

            //add listener
            renderTargetListener = new ViewRenderTargetListener( this );
            renderTexture.AddListener( renderTargetListener );

            if( guiRenderer == null )
                guiRenderer = new GuiRenderer( viewport );
            else
                guiRenderer.ChangeViewport( viewport );

            if( controlManager == null )
                controlManager = new ScreenControlManager( guiRenderer );

            //initialize D3DImage output
            if( d3dImageIsSupported && allowUsingD3DImage )
            {
                // create a D3DImage to host the scene and monitor it for changes in front buffer availability
                if( d3dImage == null )
                {
                    d3dImage = new D3DImage();
                    d3dImage.IsFrontBufferAvailableChanged += D3DImage_IsFrontBufferAvailableChanged;
                    CompositionTarget.Rendering += D3DImage_OnRendering;
                }

                // set output to background image
                Background = new ImageBrush( d3dImage );

                // set the back buffer using the new scene pointer
                HardwarePixelBuffer buffer = texture.GetBuffer( 0, 0 );
                GetD3D9HardwarePixelBufferData data = new GetD3D9HardwarePixelBufferData();
                data.hardwareBuffer = buffer._GetRealObject();
                data.outPointer = IntPtr.Zero;
                unsafe
                {
                    GetD3D9HardwarePixelBufferData* pData = &data;
                    if( !RenderSystem.Instance.CallCustomMethod( "Get D3D9HardwarePixelBuffer getSurface", (IntPtr)pData ) )
                        Log.Fatal( "Get D3D9HardwarePixelBuffer getSurface failed." );
                }
                d3dImage.Lock();
                d3dImage.SetBackBuffer( D3DResourceType.IDirect3DSurface9, data.outPointer );
                d3dImage.Unlock();
            }

            return true;
        }
示例#15
0
        /// <summary>
        /// Creates a new DrawingSurface object.
        /// </summary>
        public DrawingSurface()
        {
            // Create the d3dimage
            this.d3dimage = new D3DImage();
            this.d3dimage.IsFrontBufferAvailableChanged += D3dimage_IsFrontBufferAvailableChanged;

            // Create the image and set the source
            this.image = new Image()
            {
                Stretch = Stretch.None,
                Source = this.d3dimage
            };

            this.AddChild(this.image);

            // Initalize events
            this.Loaded += this.DrawingSurface_Loaded;
            this.Unloaded += this.DrawingSurface_Unloaded;
        }
示例#16
0
 public VideoImageSource()
 {
     m_image = new D3DImage();
     m_image.IsFrontBufferAvailableChanged += new DependencyPropertyChangedEventHandler(m_image_IsFrontBufferAvailableChanged);
     Source = m_image;
 }
示例#17
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 5 "..\..\MainWindow.xaml"
                ((TetraEditor.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);

            #line default
            #line hidden
                return;

            case 2:
                this.d3dImage = ((System.Windows.Interop.D3DImage)(target));

            #line 11 "..\..\MainWindow.xaml"
                this.d3dImage.IsFrontBufferAvailableChanged += new System.Windows.DependencyPropertyChangedEventHandler(this.d3dImage_IsFrontBufferAvailableChanged);

            #line default
            #line hidden
                return;

            case 3:
                this.Inspecter = ((System.Windows.Controls.ListBox)(target));

            #line 14 "..\..\MainWindow.xaml"
                this.Inspecter.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.Inspecter_SelectionChanged);

            #line default
            #line hidden
                return;

            case 4:

            #line 15 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click);

            #line default
            #line hidden
                return;

            case 5:
                this.Name = ((System.Windows.Controls.TextBox)(target));

            #line 17 "..\..\MainWindow.xaml"
                this.Name.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.Name_TextChanged);

            #line default
            #line hidden
                return;

            case 6:
                this.ImageSource = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 7:
                this.PosX = ((System.Windows.Controls.TextBox)(target));

            #line 24 "..\..\MainWindow.xaml"
                this.PosX.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.Pos_TextChanged);

            #line default
            #line hidden
                return;

            case 8:
                this.PosY = ((System.Windows.Controls.TextBox)(target));

            #line 26 "..\..\MainWindow.xaml"
                this.PosY.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.Pos_TextChanged);

            #line default
            #line hidden
                return;

            case 9:
                this.PosZ = ((System.Windows.Controls.TextBox)(target));

            #line 28 "..\..\MainWindow.xaml"
                this.PosZ.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.Pos_TextChanged);

            #line default
            #line hidden
                return;

            case 10:
                this.Resource = ((System.Windows.Controls.ListBox)(target));

            #line 31 "..\..\MainWindow.xaml"
                this.Resource.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.Resource_SelectionChanged);

            #line default
            #line hidden
                return;

            case 11:

            #line 32 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.ResourceButton_Click);

            #line default
            #line hidden
                return;

            case 12:

            #line 33 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.ResourceSetButton_Click);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
        public IAsyncResult BeginRender(Action renderAction, ref ImageSource backbuffer)
        {
            if (backbuffer == null)
            {
                backbuffer = new D3DImage(96, 96);
            }
            var asyncResult = new AsyncResult();
            asyncResult.AsyncState = backbuffer;

            // rendering
            RenderGLToD3dImage((D3DImage)backbuffer, Size.Width, Size.Height, renderAction);

            // finished rendering
            asyncResult._handle.Set();
            return asyncResult;
        }
        /// <summary>
        /// The render by OpenGL.
        /// </summary>
        private void RenderGLToD3dImage(D3DImage image, int w, int h, Action rendering)
        {
            if (w == 0 || h == 0)
            {
                return;
            }
            this.glControl.MakeCurrent();

            // resize D3D/OpenGL Surface if need
            this.ResizeIfNeed(w, h);

            // OnRender may be called twice in the same frame. Only render the first time.
            if (image.IsFrontBufferAvailable)
            {
                // render to sharedSurface using OpenGL
                this.wgl.WglDXLockObjectsNV(wglHandleDevice, 1, singleWglHandleSharedSurfaceArray);
                GL.BindFramebuffer(FramebufferTarget.Framebuffer, fbo);
                GL.DrawBuffer((DrawBufferMode)FramebufferAttachment.ColorAttachment0);
                rendering();
                GL.Finish();
                this.wgl.WglDXUnlockObjectsNV(wglHandleDevice, 1, singleWglHandleSharedSurfaceArray);

                try
                {
                    image.Lock();
                    image.SetBackBuffer(D3DResourceType.IDirect3DSurface9, sharedSurface.NativePointer);
                    image.AddDirtyRect(new Int32Rect(0, 0, w, h));
                }
                catch (Exception ex)
                {
                    // ???
                    Console.WriteLine(ex.ToString());
                    this.device.ResetEx(ref this.presentparams);
                }
                finally
                {
                    image.Unlock();
                }
            }
        }
示例#20
0
        public override void Dispose()
        {
            if (m_d3dImage != null)
                m_d3dImage.Dispatcher.Invoke((Action)delegate
                {
                    m_d3dImage.Lock();
                    m_d3dImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, IntPtr.Zero);
                    m_d3dImage.Unlock();
                    m_d3dImage = null;
                });

            ReleaseResources();

            base.Dispose();
        }
示例#21
0
        /// <summary>
        /// Creates a new WPFPresenter instance.
        /// </summary>
        /// <param name="directCanvas">The DirectCanvas factor this presenter belongs to</param>
        /// <param name="width">The pixel width of the presenter</param>
        /// <param name="height">The pixel height of the presenter</param>
        /// <param name="image">The WPF Image to render to</param>
        public WPFBlitPresenter(DirectCanvasFactory directCanvas, int width, int height, Image image)
            : base(directCanvas)
        {
            m_width = width;
            m_height = height;
            m_image = image;

            /* Check and see if we are on the UI thread as we may want to support
             * multi-threaded scenarios */
            if (!image.Dispatcher.CheckAccess())
            {
                image.Dispatcher.Invoke((Action)delegate
                {
                    m_d3dImage = new D3DImage();
                    image.Source = m_d3dImage;
                });
            }
            else
            {
                m_d3dImage = new D3DImage();
                image.Source = m_d3dImage;
            }

            /* Initialize our special layers */
            CreateLayer(m_width, m_height);
        }
示例#22
0
        public DX3DHost()
        {
            image = new Image();
            d3dimage = new D3DImage();
            image.Source = d3dimage;

            this.Content = image;
            this.components = new DrawableComponentsManager();
            this.camera = new Camera();

        }
示例#23
0
        /// <summary>
        /// Initialize le moteur 3D utilisé pour le rendu et le processing
        /// </summary>
        public void Initialize()
        {
            InteropImage = new D3DImage(96, 96);
            OffscreenEngineBuilder.MultiSampleCount = 4;

            RenderTargetManager.DisableMultiSampling = false;

            CurrentEngine = OffscreenEngineBuilder.CreateFromD3DImage(RenderingWidth, RenderingHeight, InteropImage);

            OffscreenEngineBuilder.MultiSampleCount = 0;
            RenderTargetManager.DisableMultiSampling = true;

            CurrentEngine.Renderer.EnableDebugKeyboardCommands = false;

            CurrentEngine.Renderer.EnableGlow = false;
            CurrentEngine.Renderer.EnableHDR = false;
            CurrentEngine.Renderer.EnableLighting = false;
            CurrentEngine.Renderer.EnableMotionBlur = false;
            CurrentEngine.Renderer.EnableShadow = false;
            CurrentEngine.Renderer.EnableToonShading = false;
            CurrentEngine.Renderer.EnableFXAA = false;

            CurrentEngine.ScreenManager.AddScreen(RenderingScreen = new SoraEngineScreen(this));

            CurrentEngine.RenderingOptions.TextureQuality = Sora.GameEngine.GameComponents.GameSystem.Rendering.Options.TextureQuality.High;
        }
示例#24
0
        /// <summary>
        /// Called when [loaded].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void OnLoaded(object sender, System.Windows.RoutedEventArgs e)
        {
            if (this.app == null)
            {
                this.app = new MainApp((int)this.ActualWidth, (int)this.ActualHeight);

                this.image = this.app.Configure() as D3DImage;

                this.InvalidateVisual();

                this.UpdateLayout();
            }

            if (this.counters == 0)
            {
                this.SizeChanged += this.OnSizeChanged;

                CompositionTargetEx.Rendering += this.CheckInit;

                this.counters++;
            }
        }
示例#25
0
 private unsafe void OnIsFrontBufferAvailableChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     // If the front buffer becomes unavailable, the D3DImage is discarded. This is for robustness since in
     // some situations the front buffer seems never to become available again.
     if (d3dImage.IsFrontBufferAvailable)
     {
         ReleaseBackBuffer();
         SetBackBuffer();
         RenderScene();
         if (surfaceType == SurfaceType.DirectX9) ResetDevice();
     }
     else
     {
         imageBrush = null;
         d3dImage.IsFrontBufferAvailableChanged -= OnIsFrontBufferAvailableChanged;
         d3dImage = null;
         if (surfaceType == SurfaceType.DirectX9 && graphicsDeviceService9.UseDeviceEx == false)
         {
             if (graphicsDeviceService9.GraphicsDevice.TestCooperativeLevel() == ResultCode.DeviceNotReset)
             {
                 ResetDevice();
             }
             ReleaseBackBuffer();
         }
     }
 }
示例#26
0
        /// <summary>
        /// Initializes the D3DRenderer control
        /// </summary>
        private void InitializeD3DVideo()
        {
            if (m_videoImage != null)
                return;

            /* Create our Image and it's D3DImage source */
            m_videoImage = new Image();
            m_d3dImage = new D3DImage();

            /* We hook into this event to handle when a D3D device is lost */
            D3DImage.IsFrontBufferAvailableChanged += D3DImageIsFrontBufferAvailableChanged;

            /* Set our default stretch value of our video */
            m_videoImage.Stretch = (Stretch)StretchProperty.DefaultMetadata.DefaultValue;
            m_videoImage.StretchDirection = (StretchDirection)StretchProperty.DefaultMetadata.DefaultValue;

            /* Our source of the video image is the D3DImage */
            m_videoImage.Source = D3DImage;

            /* Register the Image as a visual child */
            AddVisualChild(m_videoImage);

            /* Bind the horizontal alignment dp of this control to that of the video image */
            var horizontalAlignmentBinding = new Binding("HorizontalAlignment") { Source = this };
            m_videoImage.SetBinding(HorizontalAlignmentProperty, horizontalAlignmentBinding);

            /* Bind the vertical alignment dp of this control to that of the video image */
            var verticalAlignmentBinding = new Binding("VerticalAlignment") { Source = this };
            m_videoImage.SetBinding(VerticalAlignmentProperty, verticalAlignmentBinding);

            ToggleDeeperColorEffect((bool)DeeperColorProperty.DefaultMetadata.DefaultValue);
        }
示例#27
0
 public void RecreateD3DImage(bool setBackBuffer)
 {
     if (d3dImage != null) d3dImage.IsFrontBufferAvailableChanged -= OnIsFrontBufferAvailableChanged;
     d3dImage = new D3DImage();
     imageBrush = new ImageBrush(d3dImage);
     d3dImage.IsFrontBufferAvailableChanged += new DependencyPropertyChangedEventHandler(OnIsFrontBufferAvailableChanged);
     if (setBackBuffer) SetBackBuffer();
 }
示例#28
0
        public void SetD3DImage(D3DImage d3dImage, Size size)
        {
            this.d3dImage = d3dImage;

            CreateRenderTarget(size);
        }
示例#29
0
        /// <summary>
        /// Creates a new instance of the FastGLControl-class.
        /// </summary>
        public FastGLControl()
        {
            InitializeComponent();

            _image = new D3DImage();
            _image.IsFrontBufferAvailableChanged += IsFrontBufferAvailableChanged;

            Background = new ImageBrush(_image);
            Loaded += new RoutedEventHandler((object sender, RoutedEventArgs args) => { StartRendering(); });
            SizeChanged += new SizeChangedEventHandler(FastGLControl_SizeChanged);
            Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted;
        }
        public D3DImageSource(int adapterId)
        {
            this.renderLock = new object();

            this.isVistaOrBetter = IsVistaOrBetter;

            this.imageSource = new D3DImage();
            this.imageSource.IsFrontBufferAvailableChanged += this.OnIsFrontBufferAvailableChanged;

            this.InitD3D(adapterId);

            this.dummyWindow = new Form();
            this.hwnd = this.dummyWindow.Handle;
        }
示例#31
0
 public ImageUnlocker(D3DImage image)
 {
     _image = image;
 }