当前位置: 首页>>代码示例>>C#>>正文


C# IRenderContext.Render方法代码示例

本文整理汇总了C#中IRenderContext.Render方法的典型用法代码示例。如果您正苦于以下问题:C# IRenderContext.Render方法的具体用法?C# IRenderContext.Render怎么用?C# IRenderContext.Render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IRenderContext的用法示例。


在下文中一共展示了IRenderContext.Render方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Render

        public void Render(IGameContext gameContext, IRenderContext renderContext)
        {
            try
            {
                renderContext.Render(gameContext);

                _primary = _renderTargetBackBufferUtilities.UpdateRenderTarget(_primary, gameContext);
                _secondary = _renderTargetBackBufferUtilities.UpdateRenderTarget(_secondary, gameContext);

                var standardRenderPasses = _standardRenderPasses.ToArray();
                var postProcessingRenderPasses = _postProcessingRenderPasses.ToArray();
                //IRenderPass[] transientStandardRenderPasses;
                //IRenderPass[] transientPostProcessingRenderPasses;
                IRenderPass previousPass = null;
                IRenderPass nextPass = null;

                var entities = gameContext.World.Entities.ToArray();

            #if !DISABLE_PIPELINE_TARGETS
                renderContext.PushRenderTarget(_primary);
            #endif

                for (var i = 0; i < standardRenderPasses.Length; i++)
                {
                    var pass = standardRenderPasses[i];
                    _isFirstRenderPass = previousPass == null;
                    _renderPass = pass;
                    pass.BeginRenderPass(gameContext, renderContext, previousPass, null);
                    previousPass = pass;
                    RenderPass(gameContext, renderContext, entities);
                    if (i < standardRenderPasses.Length - 1)
                    {
                        nextPass = standardRenderPasses[i + 1];
                    }
                    else if (_transientStandardRenderPasses.Count > 0)
                    {
                        nextPass = _transientStandardRenderPasses[0];
                    }
                    else if (postProcessingRenderPasses.Length > 0)
                    {
                        nextPass = postProcessingRenderPasses[0];
                    }
                    else if (_transientPostProcessingRenderPasses.Count > 0)
                    {
                        nextPass = _transientPostProcessingRenderPasses[0];
                    }
                    else
                    {
                        nextPass = null;
                    }
                    pass.EndRenderPass(gameContext, renderContext, nextPass);
                }

                var loop = 100;
                while (_transientStandardRenderPasses.Count > 0 && loop-- >= 0)
                {
                    var transientStandardRenderPasses = _transientStandardRenderPasses.ToArray();
                    _transientStandardRenderPasses.Clear();

                    for (var i = 0; i < transientStandardRenderPasses.Length; i++)
                    {
                        var pass = transientStandardRenderPasses[i];
                        _isFirstRenderPass = previousPass == null;
                        _renderPass = pass;
                        pass.BeginRenderPass(gameContext, renderContext, previousPass, null);
                        previousPass = pass;
                        RenderPass(gameContext, renderContext, entities);
                        if (i < transientStandardRenderPasses.Length - 1)
                        {
                            nextPass = transientStandardRenderPasses[i + 1];
                        }
                        else if (_transientStandardRenderPasses.Count > 0)
                        {
                            nextPass = _transientStandardRenderPasses[0];
                        }
                        else if (postProcessingRenderPasses.Length > 0)
                        {
                            nextPass = postProcessingRenderPasses[0];
                        }
                        else if (_transientPostProcessingRenderPasses.Count > 0)
                        {
                            nextPass = _transientPostProcessingRenderPasses[0];
                        }
                        else
                        {
                            nextPass = null;
                        }
                        pass.EndRenderPass(gameContext, renderContext, nextPass);
                    }
                }
                if (loop < 0)
                {
                    throw new InvalidOperationException(
                        "Exceeded the number of AppendTransientRenderPass iterations (100).  Ensure you " +
                        "are not unconditionally calling AppendTransientRenderPass within another render pass.");
                }

            #if !DISABLE_PIPELINE_TARGETS
                renderContext.PopRenderTarget();
            #endif
//.........这里部分代码省略.........
开发者ID:johnsonc,项目名称:Protogame,代码行数:101,代码来源:DefaultRenderPipeline.cs

示例2: Render

        public void Render(IGameContext gameContext, IRenderContext renderContext)
        {
            try
            {
                renderContext.Render(gameContext);

                // NOTE: We MUST clear the depth buffer because OpenGL will not do it for us.
                renderContext.GraphicsDevice.Clear(
                    ClearOptions.DepthBuffer, 
                    Microsoft.Xna.Framework.Color.Transparent, 
                    renderContext.GraphicsDevice.Viewport.MaxDepth,
                    0);

                _primary = _renderTargetBackBufferUtilities.UpdateRenderTarget(_primary, gameContext);
                _secondary = _renderTargetBackBufferUtilities.UpdateRenderTarget(_secondary, gameContext);

                if (_primary == null || _secondary == null)
                {
                    // These are null if the window is minimized or invalid, in which case we don't
                    // render anything anyway.
                    return;
                }

                var standardRenderPasses = _standardRenderPasses.ToArray();
                var postProcessingRenderPasses = _postProcessingRenderPasses.ToArray();
                IRenderPass previousPass = null;
                IRenderPass nextPass = null;

                var entities = gameContext.World.GetEntitiesForWorld(gameContext.Hierarchy).ToArray();

#if !DISABLE_PIPELINE_TARGETS
                renderContext.PushRenderTarget(_primary);
#endif

                for (var i = 0; i < standardRenderPasses.Length; i++)
                {
                    var pass = standardRenderPasses[i];
                    using (_profiler.Measure("r-" + pass.GetType().Name))
                    {
                        _isFirstRenderPass = previousPass == null;
                        _renderPass = pass;
                        SetupRenderPassViewport(renderContext, pass);
                        pass.BeginRenderPass(gameContext, renderContext, previousPass, null);
                        previousPass = pass;
                        RenderPass(gameContext, renderContext, pass, entities);
                        if (i < standardRenderPasses.Length - 1)
                        {
                            nextPass = standardRenderPasses[i + 1];
                        }
                        else if (_transientStandardRenderPasses.Count > 0)
                        {
                            nextPass = _transientStandardRenderPasses[0];
                        }
                        else if (postProcessingRenderPasses.Length > 0)
                        {
                            nextPass = postProcessingRenderPasses[0];
                        }
                        else if (_transientPostProcessingRenderPasses.Count > 0)
                        {
                            nextPass = _transientPostProcessingRenderPasses[0];
                        }
                        else
                        {
                            nextPass = null;
                        }
                        pass.EndRenderPass(gameContext, renderContext, nextPass);
                    }
                }

                var loop = 100;
                while (_transientStandardRenderPasses.Count > 0 && loop-- >= 0)
                {
                    var transientStandardRenderPasses = _transientStandardRenderPasses.ToArray();
                    _transientStandardRenderPasses.Clear();

                    for (var i = 0; i < transientStandardRenderPasses.Length; i++)
                    {
                        var pass = transientStandardRenderPasses[i];
                        using (_profiler.Measure("r-" + pass.GetType().Name))
                        {
                            _isFirstRenderPass = previousPass == null;
                            _renderPass = pass;
                            SetupRenderPassViewport(renderContext, pass);
                            pass.BeginRenderPass(gameContext, renderContext, previousPass, null);
                            previousPass = pass;
                            RenderPass(gameContext, renderContext, pass, entities);
                            if (i < transientStandardRenderPasses.Length - 1)
                            {
                                nextPass = transientStandardRenderPasses[i + 1];
                            }
                            else if (_transientStandardRenderPasses.Count > 0)
                            {
                                nextPass = _transientStandardRenderPasses[0];
                            }
                            else if (postProcessingRenderPasses.Length > 0)
                            {
                                nextPass = postProcessingRenderPasses[0];
                            }
                            else if (_transientPostProcessingRenderPasses.Count > 0)
                            {
//.........这里部分代码省略.........
开发者ID:RedpointGames,项目名称:Protogame,代码行数:101,代码来源:DefaultRenderPipeline.cs


注:本文中的IRenderContext.Render方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。