Example #1
0
        private void SetD3DImageBackBuffer(RenderTarget2D renderTarget)
        {
            _d3DImage.Lock();
#if RESIZABLE
            //Get the surface from the RenderTarget2D if using one for drawing
            _d3DImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, GameReflector.GetRenderTargetSurface(renderTarget));
#else
            //If not using a RenderTarget for drawing, get the surface from the GraphicsDevice
            _d3DImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, GameReflector.GetGraphicsDeviceSurface(Game.GraphicsDevice));
#endif
            _d3DImage.Unlock();
        }
Example #2
0
        void GamePanel_Loaded(object sender, RoutedEventArgs e)
        {
            if (ReferenceEquals(Game, null))
            {
                return;
            }

            GameReflector.CreateGame(Game, _image);
            //Set the back buffer for the D3DImage, since unlocking it without one will thrown and exception
            SetD3DImageBackBuffer(CreateRenderTarget(1, 1));

#if RESIZABLE
            //Register for size changed if using a RenderTarget2D for drawing
            _image.SizeChanged += new SizeChangedEventHandler(OnSizeChanged);
#endif
            //Register for Rendering to perform updates and drawing
            System.Windows.Media.CompositionTarget.Rendering += new EventHandler(OnRendering);
        }