Пример #1
0
            public override void Draw(Device device, DeviceContext context, RenderTargetView renderTargetView)
            {
                var deviceChanged = _device != device || _context != context;

                _device  = device;
                _context = context;

                if (!_game.Initialized)
                {
                    DrawingSurfaceState.Device           = _device;
                    DrawingSurfaceState.Context          = _context;
                    DrawingSurfaceState.RenderTargetView = renderTargetView;
                    deviceChanged = false;

                    // Start running the game.
                    _game.Run(GameRunBehavior.Asynchronous);
                }

                if (deviceChanged)
                {
                    _game.GraphicsDevice.UpdateDevice(device, context);
                }
                _game.GraphicsDevice.UpdateTarget(renderTargetView);
                _game.GraphicsDevice.ResetRenderTargets();
                _game.Tick();

                _host.RequestAdditionalFrame();
            }
Пример #2
0
        public override void Draw(Device device, DeviceContext context, RenderTargetView renderTargetView)
        {
            // We just clear the render target view
            context.ClearRenderTargetView(renderTargetView, Color.CornflowerBlue);

            // Ask the DrawingSurface to call us back
            host.RequestAdditionalFrame();
        }
Пример #3
0
        void IDrawingSurfaceContentProviderNative.GetTexture(Size2F surfaceSize, out DrawingSurfaceSynchronizedTexture synchronizedTexture, out RawRectangleF textureSubRectangle)
        {
            try
            {
                if (!Exiting)
                {
                    // TODO Check if surfaceSize changed to reinitialize the buffers?
                    currentSize = surfaceSize;

                    if (!isInitialized)
                    {
                        InitCallback();
                        isInitialized = true;
                    }
                    else if (this.synchronizedTexture == null)
                    {
                        // Dispose the graphics device
                        if (graphicsDeviceService.GraphicsDevice != null)
                        {
                            graphicsDeviceService.GraphicsDevice.Dispose();
                        }

                        // Make sure that the graphics device is created
                        // This will create indirectly the synchronizedTexture on this instance.
                        graphicsDeviceManager.CreateDevice();
                    }

                    this.synchronizedTexture.BeginDraw();

                    RunCallback();

                    host.RequestAdditionalFrame();

                    this.synchronizedTexture.EndDraw();
                }
            }
            catch (Exception ex)
            {
                // TODO: As we are in a callback from a native code, we cannot pass back this exception,
                // so how to pass back this exception to the user at an appropriate time?
                drawException = ex;
                Debug.WriteLine(drawException);
            }

            // Set output parameters.
            var output = new RectangleF(0f, 0f, surfaceSize.Width, surfaceSize.Height);

            textureSubRectangle = new RawRectangleF {
                Left = output.Left, Top = output.Top, Right = output.Right, Bottom = output.Bottom
            };
            synchronizedTexture = this.synchronizedTexture;
        }
Пример #4
0
        /// <summary>
        /// Requests next rendering.
        /// </summary>
        internal void RequestNextFrame()
        {
            if (m_surfacePainter == null)
            {
                throw new ObjectDisposedException("WP8DrawingSurfaceInterop");
            }

            Interlocked.Increment(ref m_frameRequestCount);

            m_contentDirty = true;
            if (m_runtimeHost != null)
            {
                m_runtimeHost.RequestAdditionalFrame();
            }
        }
Пример #5
0
        public void Draw(Device device, DeviceContext context, RenderTargetView renderTargetView)
        {
            var deviceChanged = _device != device || _context != context;

            _device  = device;
            _context = context;

            if (deviceChanged)
            {
                DrawingSurfaceState.Device           = _device;
                DrawingSurfaceState.Context          = _context;
                DrawingSurfaceState.RenderTargetView = renderTargetView;
            }

            if (!_game.Initialized)
            {
                // Start running the game.
                _game.Run(GameRunBehavior.Asynchronous);
            }
            else if (deviceChanged)
            {
                _game.GraphicsDevice.Initialize();

                Microsoft.Xna.Framework.Content.ContentManager.ReloadGraphicsContent();

                // DeviceReset events
                _game.graphicsDeviceManager.OnDeviceReset(EventArgs.Empty);
                _game.GraphicsDevice.OnDeviceReset();
            }

            _game.GraphicsDevice.UpdateTarget(renderTargetView);
            _game.GraphicsDevice.ResetRenderTargets();
            _game.Tick();

            _host.RequestAdditionalFrame();
        }
Пример #6
0
 public override void Draw(Device device, DeviceContext context, RenderTargetView renderTargetView)
 {
     controller.Render(device, context, renderTargetView);
     host.RequestAdditionalFrame();
 }