示例#1
0
 protected virtual bool BeginDraw()
 {
     if (graphicsDeviceManager != null)
     {
         return(graphicsDeviceManager.BeginDraw());
     }
     return(true);
 }
示例#2
0
 protected virtual bool BeginDraw()
 {
     if (isFixedTimeStep && gameUpdateTime.IsRunningSlowly)
     {
         return(false);
     }
     return(graphicsManager.BeginDraw());
 }
示例#3
0
        /// <summary>
        /// Starts the drawing of a frame. This method is followed by calls to Draw and EndDraw.
        /// </summary>
        /// <returns><c>true</c> to continue drawing, false to not call <see cref="Draw"/> and <see cref="EndDraw"/></returns>
        protected virtual bool BeginDraw()
        {
            beginDrawOk = false;

            if ((graphicsDeviceManager != null) && !graphicsDeviceManager.BeginDraw())
            {
                return(false);
            }

            // Setup default command list
            if (GraphicsContext == null)
            {
                GraphicsContext = new GraphicsContext(GraphicsDevice);
                Services.AddService(GraphicsContext);
            }
            else
            {
                // Reset allocator
                GraphicsContext.ResourceGroupAllocator.Reset(GraphicsContext.CommandList);
                GraphicsContext.CommandList.Reset();
            }

            beginDrawOk = true;

            // Clear states
            GraphicsContext.CommandList.ClearState();

            // Perform begin of frame presenter operations
            if (GraphicsDevice.Presenter != null)
            {
                GraphicsContext.CommandList.ResourceBarrierTransition(GraphicsDevice.Presenter.DepthStencilBuffer, GraphicsResourceState.DepthWrite);
                GraphicsContext.CommandList.ResourceBarrierTransition(GraphicsDevice.Presenter.BackBuffer, GraphicsResourceState.RenderTarget);

                GraphicsDevice.Presenter.BeginDraw(GraphicsContext.CommandList);
            }

            return(true);
        }