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


C# IRenderContext.SetActiveTexture方法代码示例

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


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

示例1: Render

        public override void Render(IGameContext gameContext, IRenderContext renderContext)
        {
            if (!renderContext.Is3DContext)
            {
                return;
            }

            if (!this.m_NetworkAPI.WasJoin)
            {
                if (this.LocallyOwned)
                {
                    renderContext.SetActiveTexture(this.m_BlueCrateTexture.Texture);
                }
                else
                {
                    renderContext.SetActiveTexture(this.m_RedCrateTexture.Texture);
                }
            }
            else
            {
                if (this.LocallyOwned)
                {
                    renderContext.SetActiveTexture(this.m_RedCrateTexture.Texture);
                }
                else
                {
                    renderContext.SetActiveTexture(this.m_BlueCrateTexture.Texture);
                }
            }

            this.m_CrateModel.Draw(
                renderContext,
                Matrix.CreateScale(0.8f) *
                Matrix.CreateTranslation(this.X + 0.5f, this.Y + 0.5f, this.Z + 0.4f),
                this.m_CrateModel.AvailableAnimations.First().Name,
                TimeSpan.Zero);
        }
开发者ID:hach-que,项目名称:Perspective-Game,代码行数:37,代码来源:CrateEntity.cs

示例2: Render

        public override void Render(IGameContext gameContext, IRenderContext renderContext)
        {
            if (!renderContext.Is3DContext)
            {
                return;
            }

            renderContext.SetActiveTexture(this.m_GoalTexture.Texture);

            this.m_GoalModel.Draw(
                renderContext,
                Matrix.CreateScale(0.4f) *
                Matrix.CreateRotationY(MathHelper.ToRadians(this.m_Rotation++)) *
                Matrix.CreateTranslation(this.X + 0.1f, this.Y + 1f, this.Z + 0.1f),
                this.m_GoalModel.AvailableAnimations.First().Name,
                TimeSpan.Zero);
        }
开发者ID:hach-que,项目名称:Perspective-Game,代码行数:17,代码来源:GoalEntity.cs

示例3: Render

        public override void Render(IGameContext gameContext, IRenderContext renderContext)
        {
            if (!renderContext.Is3DContext)
            {
                return;
            }

            midx++;

            renderContext.SetActiveTexture(this.m_KeyTexture.Texture);

            this.m_KeyModel.Draw(
                renderContext,
                Matrix.CreateScale(1f, 1f, 0.2f) *
                Matrix.CreateScale(0.5f) *
                Matrix.CreateRotationY(MathHelper.ToRadians(midx)) *
                Matrix.CreateTranslation(this.X, this.Y + 1, this.Z),
                Animation.AnimationNullName,
                TimeSpan.Zero);
        }
开发者ID:hach-que,项目名称:Perspective-Game,代码行数:20,代码来源:KeyEntity.cs

示例4: 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

示例5: Render

        public void Render(IGameContext gameContext, IRenderContext renderContext, bool renderFull = false)
        {
            if (!renderContext.Is3DContext)
            {
                return;
            }

            if (this.m_BuffersNeedRecalculation)
            {
                this.RecalculateBuffers(renderContext);
            }

            if (renderFull)
            {
                if (this.m_FullVertexBuffer != null && this.m_FullIndexBuffer != null)
                {
                    renderContext.World = Matrix.Identity;

                    renderContext.EnableTextures();
                    renderContext.SetActiveTexture(this.m_TextureAsset.Texture);

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

                        renderContext.GraphicsDevice.Indices = this.m_FullIndexBuffer;
                        renderContext.GraphicsDevice.SetVertexBuffer(this.m_FullVertexBuffer);

                        renderContext.GraphicsDevice.DrawIndexedPrimitives(
                            PrimitiveType.TriangleList,
                            0,
                            0,
                            this.m_FullVertexBuffer.VertexCount,
                            0,
                            this.m_FullIndexBuffer.IndexCount / 3);
                    }
                }
            }
            else
            {
                if (this.m_CulledVertexBuffer != null && this.m_CulledIndexBuffer != null)
                {
                    renderContext.World = Matrix.Identity;

                    renderContext.EnableTextures();
                    renderContext.SetActiveTexture(this.m_TextureAsset.Texture);

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

                        renderContext.GraphicsDevice.Indices = this.m_CulledIndexBuffer;
                        renderContext.GraphicsDevice.SetVertexBuffer(this.m_CulledVertexBuffer);

                        renderContext.GraphicsDevice.DrawIndexedPrimitives(
                            PrimitiveType.TriangleList,
                            0,
                            0,
                            this.m_CulledVertexBuffer.VertexCount,
                            0,
                            this.m_CulledIndexBuffer.IndexCount / 3);
                    }
                }
            }

            foreach (var room in this.Rooms)
            {
                var matrix = Matrix.CreateScale(0.1f) * Matrix.CreateTranslation(room.X / 10, room.Y / 10, room.Z / 10);

                room.Render(gameContext, renderContext, null, false, matrix);
            }
        }
开发者ID:gusmanb,项目名称:Mir,代码行数:72,代码来源:Ship.cs

示例6: RenderTexture

        /// <summary>
        /// The render texture.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <param name="matrix">
        /// The matrix.
        /// </param>
        /// <param name="texture">
        /// The texture.
        /// </param>
        /// <param name="color">
        /// The color.
        /// </param>
        /// <param name="flipHorizontally">
        /// The flip horizontally.
        /// </param>
        /// <param name="flipVertically">
        /// The flip vertically.
        /// </param>
        /// <param name="sourceArea">
        /// The source area.
        /// </param>
        /// <exception cref="NotSupportedException">
        /// </exception>
        private void RenderTexture(
            IRenderContext context, 
            Matrix matrix, 
            Texture2D texture, 
            Color? color = null, 
            bool flipHorizontally = false, 
            bool flipVertically = false, 
            Rectangle? sourceArea = null)
        {
            if (color != null)
            {
                throw new NotSupportedException();
            }

            if (flipHorizontally)
            {
                throw new NotSupportedException();
            }

            if (flipVertically)
            {
                throw new NotSupportedException();
            }

            if (sourceArea != null)
            {
                throw new NotSupportedException();
            }

            context.EnableTextures();
            context.SetActiveTexture(texture);

            var vertexes = new[]
            {
                new VertexPositionTexture(Vector3.Transform(new Vector3(0, 0, 0), matrix), new Vector2(0, 1)),
                new VertexPositionTexture(Vector3.Transform(new Vector3(0, 1, 0), matrix), new Vector2(0, 0)),
                new VertexPositionTexture(Vector3.Transform(new Vector3(1, 0, 0), matrix), new Vector2(1, 1)),
                new VertexPositionTexture(Vector3.Transform(new Vector3(1, 1, 0), matrix), new Vector2(1, 0))
            };
            var indicies = new short[] { 1, 3, 0, 2 };

            context.GraphicsDevice.BlendState = BlendState.NonPremultiplied;
            foreach (var pass in context.Effect.CurrentTechnique.Passes)
            {
                pass.Apply();

                context.GraphicsDevice.DrawUserIndexedPrimitives(
                    PrimitiveType.TriangleStrip,
                    vertexes,
                    0,
                    vertexes.Length,
                    indicies,
                    0,
                    vertexes.Length - 2);
            }

            context.GraphicsDevice.BlendState = BlendState.Opaque;
        }
开发者ID:johnsonc,项目名称:Protogame,代码行数:84,代码来源:Default3DRenderUtilities.cs

示例7: RenderPlane

        public void RenderPlane(IRenderContext context, Matrix transform, TextureAsset texture, Vector2 topLeftUV,
            Vector2 bottomRightUV)
        {
            if (!context.Is3DContext)
            {
                throw new InvalidOperationException("Can't use 3D rendering utilities in 2D context.");
            }

            var vertexes = new[]
            {
                new VertexPositionNormalTexture(new Vector3(0, 0, 0), new Vector3(0, -1, 0), new Vector2(topLeftUV.X, topLeftUV.Y)),
                new VertexPositionNormalTexture(new Vector3(0, 0, 1), new Vector3(0, -1, 0), new Vector2(topLeftUV.X, bottomRightUV.Y)),
                new VertexPositionNormalTexture(new Vector3(1, 0, 0), new Vector3(0, -1, 0), new Vector2(bottomRightUV.X, topLeftUV.Y)),
                new VertexPositionNormalTexture(new Vector3(1, 0, 1), new Vector3(0, -1, 0), new Vector2(bottomRightUV.X, bottomRightUV.Y)),
            };

            var indicies = new short[]
            {
                0, 2, 1,
                3, 1, 2,
            };

            context.EnableTextures();
            context.SetActiveTexture(texture.Texture);

            var world = context.World;

            context.World = transform;

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

                context.GraphicsDevice.DrawUserIndexedPrimitives(
                    PrimitiveType.TriangleList,
                    vertexes,
                    0,
                    vertexes.Length,
                    indicies,
                    0,
                    indicies.Length / 3);
            }

            context.World = world;
        }
开发者ID:johnsonc,项目名称:Protogame,代码行数:45,代码来源:Default3DRenderUtilities.cs

示例8: RenderLine

        /// <summary>
        /// Renders a 3D line using texture UVs.
        /// </summary>
        /// <param name="context">
        /// The rendering context.
        /// </param>
        /// <param name="start">
        /// The start of the line.
        /// </param>
        /// <param name="end">
        /// The end of the line.
        /// </param>
        /// <param name="texture">
        /// The texture to use.
        /// </param>
        /// <param name="startUV">
        /// The UV for the start of the line.
        /// </param>
        /// <param name="endUV">
        /// The UV for the end of the line.
        /// </param> 
        public void RenderLine(
            IRenderContext context,
            Vector3 start, 
            Vector3 end,
            TextureAsset texture,
            Vector2 startUV,
            Vector2 endUV)
        {
            if (!context.Is3DContext)
            {
                throw new InvalidOperationException("Can't use 3D rendering utilities in 2D context.");
            }

            context.EnableTextures();
            context.SetActiveTexture(texture.Texture);

            var vertexes = new[] { new VertexPositionTexture(start, startUV), new VertexPositionTexture(end, endUV) };
            var indicies = new short[] { 0, 1 };

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

                context.GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.LineList, vertexes, 0, 2, indicies, 0, 1);
            }
        }
开发者ID:johnsonc,项目名称:Protogame,代码行数:47,代码来源:Default3DRenderUtilities.cs

示例9: Render

        public override void Render(IGameContext gameContext, IRenderContext renderContext)
        {
            // Render the LEM1802 to a texture
            if (this.m_LEM1802 != null)
            {
                this.RenderDCPU(renderContext);
            }
            else
            {
                if (this.m_RenderTarget == null)
                {
                    this.m_RenderTarget = new RenderTarget2D(renderContext.GraphicsDevice, LEM1802.Width, LEM1802.Height);
                }

                renderContext.PushRenderTarget(this.m_RenderTarget);
                renderContext.GraphicsDevice.Clear(Color.Black);
                renderContext.PopRenderTarget();
            }

            if (this.m_PendRecalculation)
            {
                this.RecalculateObject(gameContext, renderContext);
            }

            renderContext.GraphicsDevice.Indices = this.m_IndexBuffer;
            renderContext.GraphicsDevice.SetVertexBuffer(this.m_VertexBuffer);

            renderContext.SetActiveTexture(this.m_RenderTarget);

            renderContext.GraphicsDevice.DrawIndexedPrimitives(
                PrimitiveType.TriangleList,
                0,
                0,
                this.m_VertexBuffer.VertexCount,
                0,
                this.m_IndexBuffer.IndexCount / 3);

            renderContext.SetActiveTexture(this.m_ShipTextureAsset.Texture);

            this.m_TouchAnimIndex++;
            if (this.m_TouchAnimIndex >= this.m_TouchAnim.Length * 3)
            {
                this.m_TouchAnimIndex = 0;
            }
        }
开发者ID:gusmanb,项目名称:Mir,代码行数:45,代码来源:LEM1802RoomObject.cs

示例10: RenderCube

        public void RenderCube(IRenderContext renderContext, Matrix transform, TextureAsset texture, Vector2 topLeftUV, Vector2 bottomRightUV)
        {
            var vertexes = new[]
            {
                new VertexPositionNormalTexture(new Vector3(0, 0, 0), new Vector3(-1, 0, 0), new Vector2(topLeftUV.X, topLeftUV.Y)),
                new VertexPositionNormalTexture(new Vector3(0, 0, 1), new Vector3(-1, 0, 0), new Vector2(topLeftUV.X, bottomRightUV.Y)),
                new VertexPositionNormalTexture(new Vector3(0, 1, 0), new Vector3(-1, 0, 0), new Vector2(bottomRightUV.X, topLeftUV.Y)),
                new VertexPositionNormalTexture(new Vector3(0, 1, 1), new Vector3(-1, 0, 0), new Vector2(bottomRightUV.X, bottomRightUV.Y)),

                new VertexPositionNormalTexture(new Vector3(1, 0, 0), new Vector3(1, 0, 0), new Vector2(topLeftUV.X, topLeftUV.Y)),
                new VertexPositionNormalTexture(new Vector3(1, 0, 1), new Vector3(1, 0, 0), new Vector2(topLeftUV.X, bottomRightUV.Y)),
                new VertexPositionNormalTexture(new Vector3(1, 1, 0), new Vector3(1, 0, 0), new Vector2(bottomRightUV.X, topLeftUV.Y)),
                new VertexPositionNormalTexture(new Vector3(1, 1, 1), new Vector3(1, 0, 0), new Vector2(bottomRightUV.X, bottomRightUV.Y)),

                new VertexPositionNormalTexture(new Vector3(0, 0, 0), new Vector3(0, -1, 0), new Vector2(topLeftUV.X, topLeftUV.Y)),
                new VertexPositionNormalTexture(new Vector3(0, 0, 1), new Vector3(0, -1, 0), new Vector2(topLeftUV.X, bottomRightUV.Y)),
                new VertexPositionNormalTexture(new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector2(topLeftUV.X, topLeftUV.Y)),
                new VertexPositionNormalTexture(new Vector3(0, 1, 1), new Vector3(0, 1, 0), new Vector2(topLeftUV.X, bottomRightUV.Y)),

                new VertexPositionNormalTexture(new Vector3(1, 0, 0), new Vector3(0, -1, 0), new Vector2(bottomRightUV.X, topLeftUV.Y)),
                new VertexPositionNormalTexture(new Vector3(1, 0, 1), new Vector3(0, -1, 0), new Vector2(bottomRightUV.X, bottomRightUV.Y)),
                new VertexPositionNormalTexture(new Vector3(1, 1, 0), new Vector3(0, 1, 0), new Vector2(bottomRightUV.X, topLeftUV.Y)),
                new VertexPositionNormalTexture(new Vector3(1, 1, 1), new Vector3(0, 1, 0), new Vector2(bottomRightUV.X, bottomRightUV.Y)),

                new VertexPositionNormalTexture(new Vector3(0, 0, 0), new Vector3(0, 0, -1), new Vector2(topLeftUV.X, topLeftUV.Y)),
                new VertexPositionNormalTexture(new Vector3(0, 0, 1), new Vector3(0, 0, 1), new Vector2(topLeftUV.X, topLeftUV.Y)),
                new VertexPositionNormalTexture(new Vector3(0, 1, 0), new Vector3(0, 0, -1), new Vector2(topLeftUV.X, bottomRightUV.Y)),
                new VertexPositionNormalTexture(new Vector3(0, 1, 1), new Vector3(0, 0, 1), new Vector2(topLeftUV.X, bottomRightUV.Y)),

                new VertexPositionNormalTexture(new Vector3(1, 0, 0), new Vector3(0, 0, -1), new Vector2(bottomRightUV.X, topLeftUV.Y)),
                new VertexPositionNormalTexture(new Vector3(1, 0, 1), new Vector3(0, 0, 1), new Vector2(bottomRightUV.X, topLeftUV.Y)),
                new VertexPositionNormalTexture(new Vector3(1, 1, 0), new Vector3(0, 0, -1), new Vector2(bottomRightUV.X, bottomRightUV.Y)),
                new VertexPositionNormalTexture(new Vector3(1, 1, 1), new Vector3(0, 0, 1), new Vector2(bottomRightUV.X, bottomRightUV.Y)),
            };

            var indicies = new short[]
            {
                0, 2, 1,
                3, 1, 2,

                4, 5, 6,
                7, 6, 5,

                0 + 8, 1 + 8, 4 + 8,
                5 + 8, 4 + 8, 1 + 8,

                2 + 8, 6 + 8, 3 + 8,
                7 + 8, 3 + 8, 6 + 8,

                0 + 16, 4 + 16, 2 + 16,
                6 + 16, 2 + 16, 4 + 16,

                1 + 16, 3 + 16, 5 + 16,
                7 + 16, 5 + 16, 3 + 16
            };

            renderContext.EnableTextures();
            renderContext.SetActiveTexture(texture.Texture);

            var world = renderContext.World;

            renderContext.World = transform;

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

                renderContext.GraphicsDevice.DrawUserIndexedPrimitives(
                    PrimitiveType.TriangleList,
                    vertexes,
                    0,
                    vertexes.Length,
                    indicies,
                    0,
                    indicies.Length / 3);
            }

            renderContext.World = world;
        }
开发者ID:hach-que,项目名称:Perspective-Game,代码行数:79,代码来源:DefaultCubeRenderer.cs

示例11: Render

        public override void Render(IGameContext gameContext, IRenderContext renderContext)
        {
            if (!renderContext.Is3DContext)
                return;

            if (this.m_GrassAsset == null)
                return;

            var vertexes = new[]
            {
                new VertexPositionTexture(new Vector3(0, 0, 0), new Vector2(0, 0)),
                new VertexPositionTexture(new Vector3(0, 0, 1), new Vector2(0, 1)),
                new VertexPositionTexture(new Vector3(0, 1, 0), new Vector2(1, 0)),
                new VertexPositionTexture(new Vector3(0, 1, 1), new Vector2(1, 1)),
                new VertexPositionTexture(new Vector3(1, 0, 0), new Vector2(0, 0)),
                new VertexPositionTexture(new Vector3(1, 0, 1), new Vector2(0, 1)),
                new VertexPositionTexture(new Vector3(1, 1, 0), new Vector2(1, 0)),
                new VertexPositionTexture(new Vector3(1, 1, 1), new Vector2(1, 1))
            };

            var indicies = new short[]
            {
                0, 2, 1, 1, 2, 3,
                4, 5, 6, 5, 7, 6,
                0, 4, 6, 0, 6, 2,
                1, 7, 5, 1, 3, 7,
                0, 1, 4, 5, 4, 1,
                6, 3, 2, 7, 3, 6
            };

            var oldWorld = renderContext.World;

            renderContext.EnableTextures();
            renderContext.SetActiveTexture(this.m_GrassAsset.Texture);
            renderContext.World =
                Matrix.CreateRotationY(MathHelper.ToRadians(this.m_Rotation)) *
                Matrix.CreateTranslation(new Vector3(this.X, this.Y, this.Z));

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

                renderContext.GraphicsDevice.DrawUserIndexedPrimitives(
                    PrimitiveType.TriangleList,
                    vertexes,
                    0, // vertex buffer offset to add to each element of the index buffer
                    8, // number of vertices to draw
                    indicies,
                    0, // first index element to read
                    indicies.Length / 3);
            }

            renderContext.World = oldWorld;
        }
开发者ID:TreeSeed,项目名称:Tychaia,代码行数:54,代码来源:BackgroundCubeEntity.cs

示例12: Render

        public void Render(
            IGameContext gameContext, 
            IRenderContext renderContext, 
            RoomObject focused, 
            bool renderFocusedTransparently, 
            Matrix? matrix = null)
        {
            if (this.m_RefreshBuffers)
            {
                this.RefreshBuffers(renderContext);
                this.m_RefreshBuffers = false;
            }

            var oldWorld = renderContext.World;

            renderContext.World = matrix ?? Matrix.Identity;

            renderContext.EnableTextures();
            renderContext.SetActiveTexture(this.m_TextureAsset.Texture);

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

                this.RenderRoom(renderContext);

                foreach (var obj in this.m_RoomObjects)
                {
                    if (renderFocusedTransparently && obj == focused)
                    {
                        continue;
                    }

                    obj.Render(gameContext, renderContext);
                }
            }

            if (renderFocusedTransparently && focused != null && this.m_RoomObjects.Contains(focused))
            {
                renderContext.GraphicsDevice.BlendState = BlendState.AlphaBlend;
                renderContext.Effect.Parameters["Alpha"].SetValue(0.5f);

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

                    focused.Render(gameContext, renderContext);
                }

                renderContext.Effect.Parameters["Alpha"].SetValue(1f);
            }

            renderContext.GraphicsDevice.BlendState = BlendState.Opaque;

            renderContext.World = oldWorld;
        }
开发者ID:gusmanb,项目名称:Mir,代码行数:56,代码来源:Room.cs

示例13: RenderAbove

        public virtual void RenderAbove(IGameContext gameContext, IRenderContext renderContext)
        {
            this.m_PlayerModel.LoadBuffers(renderContext.GraphicsDevice);

            if (renderContext.Is3DContext)
            {
                renderContext.SetActiveTexture(this.m_PlayerModelTexture.Texture);

                renderContext.GraphicsDevice.RasterizerState = RasterizerState.CullClockwise;

                this.m_PlayerModel.Draw(
                    renderContext,
                    Matrix.CreateRotationY(-MathHelper.PiOver4) * Matrix.CreateScale(0.2f),
                    "walk",
                    gameContext.GameTime.TotalGameTime);

                renderContext.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;

                return;
            }

            this.m_CanvasEntity.Render(gameContext, renderContext);

            this.m_2DRenderUtilities.RenderText(
                renderContext,
                new Vector2(gameContext.Window.ClientBounds.Center.X, 50),
                this.Title == null ? string.Empty : this.Title.Value,
                this.m_TitleFont,
                HorizontalAlignment.Center);
        }
开发者ID:TreeSeed,项目名称:Tychaia,代码行数:30,代码来源:MenuWorld.cs

示例14: 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

示例15: Render

        public override void Render(IGameContext gameContext, IRenderContext renderContext)
        {
            if (!renderContext.Is3DContext)
            {
                return;
            }

            renderContext.SetActiveTexture(this.m_DoorTexture.Texture);

            var midx = this.Open ? 90 : 0;

            this.m_DoorFrameModel.Draw(
                renderContext,
                Matrix.CreateScale(0.8f) *
                Matrix.CreateTranslation(0f, 0f, 0.4f) *
                Matrix.CreateRotationY(MathHelper.ToRadians(this.m_Rotation)) *
                Matrix.CreateTranslation(this.X, this.Y, this.Z),
                this.m_DoorFrameModel.AvailableAnimations.First().Name,
                TimeSpan.Zero);

            this.m_DoorModel.Draw(
                renderContext,
                Matrix.CreateTranslation(0.5f, 0f, 0f) *
                Matrix.CreateRotationY(MathHelper.ToRadians(midx)) *
                Matrix.CreateTranslation(-0.5f, 0f, 0f) *
                Matrix.CreateScale(0.8f) *
                Matrix.CreateTranslation(0f, 0f, 0.4f) *
                Matrix.CreateRotationY(MathHelper.ToRadians(this.m_Rotation)) *
                Matrix.CreateTranslation(this.X, this.Y, this.Z),
                this.m_DoorModel.AvailableAnimations.First().Name,
                TimeSpan.Zero);
        }
开发者ID:hach-que,项目名称:Perspective-Game,代码行数:32,代码来源:DoorEntity.cs


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