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


C# IRenderContext.PopEffect方法代码示例

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


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

示例1: Render

        /// <summary>
        /// Renders the specified chunk with the specified rendering context.
        /// </summary>
        /// <param name="renderContext">The rendering context.</param>
        /// <param name="runtimeChunk">The runtime chunk to render.</param>
        public void Render(IRenderContext renderContext, IChunk runtimeChunk)
        {
            if (!renderContext.Is3DContext)
            {
                return;
            }

            if (runtimeChunk.GraphicsEmpty)
            {
                return;
            }

            if (runtimeChunk.Generated && runtimeChunk.VertexBuffer == null && runtimeChunk.IndexBuffer == null)
            {
                this.CalculateBuffers(renderContext, runtimeChunk);
            }

            if (runtimeChunk.VertexBuffer != null && runtimeChunk.IndexBuffer != null)
            {
                renderContext.PushEffect(this.m_TerrainEffectAsset.Effect);

                renderContext.EnableTextures();
                renderContext.SetActiveTexture(this.m_TextureAtlasAsset.TextureAtlas.Texture);
                renderContext.GraphicsDevice.Indices = runtimeChunk.IndexBuffer;
                renderContext.GraphicsDevice.SetVertexBuffer(runtimeChunk.VertexBuffer);
                renderContext.World = Matrix.CreateScale(32);
                foreach (var pass in renderContext.Effect.CurrentTechnique.Passes)
                {
                    pass.Apply();
                    renderContext.GraphicsDevice.DrawIndexedPrimitives(
                        PrimitiveType.TriangleList,
                        0,
                        0,
                        runtimeChunk.VertexBuffer.VertexCount,
                        0,
                        runtimeChunk.IndexBuffer.IndexCount / 3);
                }

                renderContext.PopEffect();
            }
        }
开发者ID:TreeSeed,项目名称:Tychaia,代码行数:46,代码来源:DefaultChunkRenderer.cs

示例2: RenderAbove

        public void RenderAbove(IGameContext gameContext, IRenderContext renderContext)
        {
            if (renderContext.Is3DContext)
            {
                renderContext.PopEffect();

                return;
            }

            for (var i = 0; i < this.m_ShipTools.Length; i++)
            {
                var tool = this.m_ShipTools[i];

                var texture = this.m_AssetManager.Get<TextureAsset>(tool.TextureName);

                this.m_2DRenderUtilities.RenderRectangle(
                    renderContext,
                    new Rectangle(16, 16 + (i * 32), 24, 24),
                    this.m_ActiveTool == i ? Color.Orange : Color.Black,
                    true);

                if (this.m_ActiveTool == i)
                {
                    this.m_2DRenderUtilities.RenderText(
                        renderContext,
                        new Vector2(16 + 32, 16 + (i * 32) + 5),
                        this.m_ShipTools[this.m_ActiveTool].Name,
                        this.m_DefaultFont);
                }

                this.m_2DRenderUtilities.RenderTexture(renderContext, new Vector2(20, 20 + (i * 32)), texture);
            }
        }
开发者ID:gusmanb,项目名称:Mir,代码行数:33,代码来源:ShipEditorWorld.cs

示例3: Blit

        public void Blit(IRenderContext renderContext, RenderTarget2D source, RenderTarget2D destination = null, Effect shader = null)
        {
            float destWidth, destHeight;
            if (destination != null)
            {
                renderContext.PushRenderTarget(destination);
                destWidth = destination.Width;
                destHeight = destination.Height;
            }
            else
            {
                // TODO: renderContext.GraphicsDevice.GetRenderTargets();
                destWidth = renderContext.GraphicsDevice.PresentationParameters.BackBufferWidth;
                destHeight = renderContext.GraphicsDevice.PresentationParameters.BackBufferHeight;
            }

            if (shader == null)
            {
                shader = _blitEffect;
            }

            if (_vertexBuffer == null)
            {
                _vertexBuffer = new VertexBuffer(renderContext.GraphicsDevice, typeof (VertexPositionTexture),
                    _vertexes.Length, BufferUsage.WriteOnly);
                _vertexBuffer.SetData(_vertexes);
            }

            if (_indexBuffer == null)
            {
                _indexBuffer = new IndexBuffer(renderContext.GraphicsDevice, typeof (short), _indicies.Length,
                    BufferUsage.WriteOnly);
                _indexBuffer.SetData(_indicies);
            }

            var oldWorld = renderContext.World;
            var oldProjection = renderContext.Projection;
            var oldView = renderContext.View;

            renderContext.GraphicsDevice.BlendState = BlendState.Opaque;
            renderContext.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
            renderContext.GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;
            renderContext.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;

            renderContext.World = Matrix.CreateScale(destWidth, destHeight, 1);
            #if PLATFORM_WINDOWS
            renderContext.Projection = Matrix.CreateOrthographicOffCenter(0, destWidth, destHeight, 0, 0, 1);
            #else
            renderContext.Projection = Matrix.CreateTranslation(-0.5f, -0.5f, 0) *
                Matrix.CreateOrthographicOffCenter(0, destWidth, destHeight, 0, 0, 1);
            #endif
            renderContext.View = Matrix.Identity;

            renderContext.PushEffect(shader);

            renderContext.EnableTextures();
            renderContext.SetActiveTexture(source);

            renderContext.GraphicsDevice.SetVertexBuffer(_vertexBuffer);
            renderContext.GraphicsDevice.Indices = _indexBuffer;

            foreach (var pass in shader.CurrentTechnique.Passes)
            {
                pass.Apply();

                renderContext.GraphicsDevice.DrawIndexedPrimitives(
                    PrimitiveType.TriangleStrip,
                    0,
                    0,
                    4,
                    0,
                    2);
            }

            renderContext.PopEffect();

            renderContext.World = oldWorld;
            renderContext.Projection = oldProjection;
            renderContext.View = oldView;

            if (destination != null)
            {
                renderContext.PopRenderTarget();
            }
        }
开发者ID:johnsonc,项目名称:Protogame,代码行数:85,代码来源:DefaultGraphicsBlit.cs


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