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


C# Renderer.Begin方法代码示例

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


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

示例1: DrawToFBO

        public void DrawToFBO(Renderer renderer)
        {
            if (lines.Count > 0 || fadeOutLines.Count > 0)
            {
                renderer.End();
                renderer.Begin();
                for (int i = 0; i < lines.Count; i++)
                {
                    renderer.GraphicsDevice.Textures[0] = GraphicsEngine.pixel;
                    lines[i].Draw(renderer);
                }
                for (int i = 0; i < fadeOutLines.Count; i++)
                {
                    renderer.GraphicsDevice.Textures[0] = GraphicsEngine.pixel;
                    fadeOutLines[i].Draw(renderer);
                }
                renderer.End();

                for (int i = 0; i < lines.Count; i++)
                {
                    lines[i].DrawArrow(renderer);
                }
                for (int i = 0; i < fadeOutLines.Count; i++)
                {
                    fadeOutLines[i].DrawArrow(renderer);
                }

                renderer.BeginUnscaled();
            }

            for (int i = 0; i < tooltips.Count; i++)
            {
                tooltips[i].Draw(renderer);
            }
        }
开发者ID:XZelnar,项目名称:MicroWorld,代码行数:35,代码来源:MagnetOverlay.cs

示例2: Draw

 public override void Draw(Renderer r)
 {
     r.End();
     _setUpShader();
     r.BeginUnscaled(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone,
             Graphics.Effects.Effects.shockWave);
     r.Draw(Shortcuts.pixel, new Rectangle(0, 0, Main.WindowWidth, Main.WindowHeight), color * 0.75f);
     r.End();
     r.Begin();
 }
开发者ID:XZelnar,项目名称:MicroWorld,代码行数:10,代码来源:EMPShockWave.cs

示例3: BeginGaussianBlur

        public static void BeginGaussianBlur(int radius, float viewportWidth, float viewportHeight, Renderer renderer)
        {
            if (radius < 1)
                radius = 1;

            if (renderer.IsDrawing)
                renderer.End();

            float[] pixelSize = new float[] { 1f / viewportWidth, 1f / viewportHeight };
            if (radius > 5)
            {
                pixelSize[0] *= radius / 5;
                pixelSize[1] *= radius / 5;
                radius = 5;
            }

            //Pascal's triangle

            float[] kernel = new float[radius * 2 + 1];
            float[] t = new float[kernel.Length];
            float[] p;
            t[0] = 1;
            kernel[0] = 1;
            kernel[1] = 1;
            for (int i = 2; i < kernel.Length; i++)
            {
                for (int j = 1; j < i; j++)
                    t[j] = kernel[j] + kernel[j - 1];
                t[i] = 1;

                p = t;
                t = kernel;
                kernel = p;
            }

            float sum = 1;
            for (int i = 1; i < kernel.Length; i++)
                sum += kernel[i];

            for (int i = 0; i < kernel.Length; i++)
                kernel[i] /= sum;

            //actual shader setup

            Matrix projection = Matrix.CreateOrthographicOffCenter(0, viewportWidth, viewportHeight, 0, 0, 1);
            Matrix halfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0);
            gaussianBlur.Parameters["MatrixTransform"].SetValue(renderer.GetTransformMatrix() * halfPixelOffset * projection);
            gaussianBlur.Parameters["range"].SetValue(radius);
            gaussianBlur.Parameters["pixelSize"].SetValue(pixelSize);
            gaussianBlur.Parameters["kernel"].SetValue(kernel);

            renderer.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, RasterizerState.CullNone, gaussianBlur);
        }
开发者ID:XZelnar,项目名称:MicroWorld,代码行数:53,代码来源:Effects.cs

示例4: Draw

 public override void Draw(Renderer renderer)
 {
     renderer.End();
     renderer.Begin();
     try
     {
         Components.ComponentsManager.Draw();
     }
     catch { }
     renderer.End();
     renderer.BeginUnscaled();
     renderer.Draw(GraphicsEngine.pixel, new Rectangle(0, 0, Main.WindowWidth, Main.WindowHeight), new Color(45, 57, 107) * 0.75f);
 }
开发者ID:XZelnar,项目名称:MicroWorld,代码行数:13,代码来源:ComponentsBackground.cs

示例5: Draw

        public void Draw(Renderer renderer)
        {
            var vr = MicroWorld.Graphics.GraphicsEngine.camera.VisibleRectangle;

            Matrix projection = Matrix.CreateOrthographicOffCenter(vr.X, vr.X + vr.Width, vr.Y + vr.Height, vr.Y, 0, 1);
            MicroWorld.Graphics.GraphicsEngine.ComponentFadeEffect.Parameters["MatrixTransform"].SetValue(projection);
            MicroWorld.Graphics.GraphicsEngine.ComponentFadeEffect.Parameters["halfpixel"].SetValue(
                new float[] { 0.5f / vr.Width, 0.5f / vr.Height });
            MicroWorld.Graphics.GraphicsEngine.ComponentFadeEffect.Parameters["Opacity"].SetValue(
                (float)(AliveState < 10 ? (float)AliveState / 10f :
                                                   (float)(10 - (AliveState - 10)) / 10f));
            MicroWorld.Graphics.GraphicsEngine.ComponentFadeEffect.Parameters["Drawtex"].SetValue(
                AliveState >= 10);
            renderer.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointWrap, DepthStencilState.None, RasterizerState.CullNone,
                MicroWorld.Graphics.GraphicsEngine.ComponentFadeEffect);

            //renderer.Draw(fbo, new Vector2(), Color.White);
            g.Draw(renderer);
            renderer.End();
        }
开发者ID:XZelnar,项目名称:MicroWorld,代码行数:20,代码来源:RemovingComponentVisuals.cs

示例6: Draw

        public override void Draw(Renderer r)
        {
            Matrix projection = Matrix.CreateOrthographicOffCenter(0,
                Main.renderer.GraphicsDevice.Viewport.Width, Main.renderer.GraphicsDevice.Viewport.Height, 0, 0, 1);
            Matrix halfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0);
            Effects.Effects.lightning.Parameters["MatrixTransform"].SetValue(r.GetTransformMatrix() * halfPixelOffset * projection);
            float[] p = new float[]{
                    1f/fbo.Width,
                    1f/fbo.Height};
            Effects.Effects.lightning.Parameters["pixel"].SetValue(p);

            r.End();
            r.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone,
                Effects.Effects.lightning);
            Vector2 o = new Vector2(32, fbo.Height / 2);
            r.Draw(fbo, new Rectangle((int)Position.X, (int)Position.Y, fbo.Width / 4, fbo.Height / 4), null,
                Color.White, rot, o);
            r.End();
            r.Begin();
        }
开发者ID:XZelnar,项目名称:MicroWorld,代码行数:20,代码来源:Lightning.cs

示例7: Draw

        public override void Draw(Renderer renderer)
        {
            if (Main.curState.StartsWith("GAME"))
            {
                //Grid
                #region Grid
                MicroWorld.Graphics.GUI.GridDraw.DrawGrid();
                #endregion

                //AoE-s
                #region AoE-s
                renderer.End();
                renderer.BeginUnscaled(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.AnisotropicClamp, DepthStencilState.None, RasterizerState.CullNone);
                LightAOE.Draw(renderer);
                MagnetAOE.Draw(renderer);
                renderer.End();
                renderer.Begin();
                #endregion

                //Components
                #region Components
                Components.ComponentsManager.Draw();
                Components.ComponentsManager.PostDraw();
                #endregion

                //SelectedGhost
                #region SelectedGhost
                if (MicroWorld.Graphics.GUI.GUIEngine.s_componentSelector.SelectedComponent.Text != "Cursor" &&
                    InputEngine.curMouse.X > GUI.Scene.ComponentSelector.CSTile.SIZE_X && !Logics.GameInputHandler.isLine)// &&
                //!MicroWorld.Graphics.GUI.GUIEngine.s_componentSelector.SelectedComponent.IsComponentOfType<Components.Properties.IDragDropPlacable>())
                {
                    int x = (int)((InputEngine.curMouse.X) / Settings.GameScale - Settings.GameOffset.X);
                    int y = (int)((InputEngine.curMouse.Y) / Settings.GameScale - Settings.GameOffset.Y);
                    Components.Component.Rotation rot = Logics.GameInputHandler.GhostRotation;
                    Vector2 size = MicroWorld.Graphics.GUI.GUIEngine.s_componentSelector.SelectedComponentGraphics.GetSizeRotated(rot);
                    Logics.GridHelper.GridCoords(ref x, ref y);
                    Logics.PlacableAreasManager.MakePlacable(ref x, ref y, (int)size.X, (int)size.Y);
                    Logics.GridHelper.GridCoords(ref x, ref y);
                    Vector2 so = MicroWorld.Graphics.GUI.GUIEngine.s_componentSelector.SelectedComponentGraphics.GetCenter(rot);
                    int nx = x - (int)so.X, ny = y - (int)so.Y;

                    bool b = GraphicsEngine.CanDrawGhostComponent(ref nx, ref ny, (int)size.X, (int)size.Y);

                    Color c = Main.renderer.Overlay;
                    if (!b)
                        renderer.Overlay = Color.Red * 0.5f;
                    if (InputEngine.curMouse.LeftButton == ButtonState.Pressed &&
                        GUI.GUIEngine.s_componentSelector.SelectedComponent.Avalable == 0)
                        Main.renderer.Overlay = Main.Ticks % 40 < 20 ? Color.Red : c;
                    MicroWorld.Graphics.GUI.GUIEngine.s_componentSelector.SelectedComponentGraphics.DrawGhost(
                        nx,
                        ny,
                        Main.renderer, Logics.GameInputHandler.GhostRotation);
                    Main.renderer.Overlay = c;

                    #region Dotted Lines
                    MicroWorld.Graphics.GUI.GUIEngine.s_componentSelector.SelectedComponentGraphics.DrawBorder(
                        nx, ny, Logics.GameInputHandler.GhostRotation, renderer);
                    #endregion
                }
                #endregion

                //RemovingComponentsVisuals
                #region RemovingComponentsVisuals
                MicroWorld.Graphics.Effects.Effects.DrawRemovingVisuals();
                #endregion

                //MouseOverComponent
                #region MouseOverComponent
                if (Logics.GameInputHandler.MouseOverComponent != null)
                {
                    Logics.GameInputHandler.MouseOverComponent.Graphics.DrawBorder(renderer);
                }
                #endregion

                //wire
                #region Wire
                if (Logics.GameInputHandler.isLine)
                {
                    lock (Logics.GameInputHandler.pendingWirePath)
                        Components.Graphics.WireGraphics.DrawWire(Logics.GameInputHandler.pendingWirePath);

                    #region Dotted Lines
                    if (Logics.GameInputHandler.pendingWirePath != null && Logics.GameInputHandler.pendingWirePath.Count > 0)
                    {
                        //optimization
                        List<Vector2> l = new List<Vector2>();
                        Vector2 v1 = new Vector2(), v2 = new Vector2();
                        lock (Logics.GameInputHandler.pendingWirePath)
                        {
                            l.Add(new Vector2(Logics.GameInputHandler.pendingWirePath[0].X, Logics.GameInputHandler.pendingWirePath[0].Y));
                            for (int i = 1; i < Logics.GameInputHandler.pendingWirePath.Count - 1; i++)
                            {
                                v1 = new Vector2(Logics.GameInputHandler.pendingWirePath[i].X - Logics.GameInputHandler.pendingWirePath[i - 1].X,
                                                 Logics.GameInputHandler.pendingWirePath[i].Y - Logics.GameInputHandler.pendingWirePath[i - 1].Y);
                                v2 = new Vector2(Logics.GameInputHandler.pendingWirePath[i + 1].X - Logics.GameInputHandler.pendingWirePath[i].X,
                                                 Logics.GameInputHandler.pendingWirePath[i + 1].Y - Logics.GameInputHandler.pendingWirePath[i].Y);

                                if (((v1.X != 0) != (v2.X != 0)) ||
                                    (v1.Y != 0) != (v2.Y != 0))
//.........这里部分代码省略.........
开发者ID:XZelnar,项目名称:MicroWorld,代码行数:101,代码来源:GameScene.cs

示例8: DrawArrow

 public void DrawArrow(Renderer renderer)
 {
     if (p1.Position == p2.Position)
         return;
     r = (c1 as Components.Properties.IMagnetic).GetRadius();
     t = (float)Main.Ticks % length;
     if (r > 0)
         a = Vector2.Lerp(c1.Graphics.Center, c2.Graphics.Center, t / length);
     else
         a = Vector2.Lerp(c2.Graphics.Center, c1.Graphics.Center, t / length);
     m = Matrix.CreateTranslation(new Vector3(-16, -16, 0)) * Matrix.CreateScale(0.15f, 0.2f, 1f) *
         arrowMatrix * Matrix.CreateRotationZ(r > 0 ? 0 : (float)Math.PI) * Matrix.CreateTranslation(new Vector3(a, 0));
     renderer.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone,
         null, m, true);
     renderer.Draw(arrow, new Vector2(), (r > 0 ? Color.Red : Color.LightBlue) * opacity * (t < 20 ? t / 20f : t > length - 20 ? (-t + length) / 20f : 1f));
     renderer.End();
 }
开发者ID:XZelnar,项目名称:MicroWorld,代码行数:17,代码来源:MagnetOverlay.cs


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