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


C# RenderTarget.Clear方法代码示例

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


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

示例1: Draw

 public override void Draw(RenderTarget target, RenderStates states)
 {
     target.Clear(Color.Black);
     target.Draw(_backgroundSprite);
     foreach (var w in Widgets)
     {
         target.Draw(w);
     }
 }
开发者ID:Tetramputechture,项目名称:Ending_0.1b,代码行数:9,代码来源:MainMenuScreen.cs

示例2: Draw

 public static void Draw(RenderTarget surface)
 {
     if (EntityToFollow != null)
     {
         surface.SetView (new View(EntityToFollow.GetPosition (), surface.GetView ().Size));
     }
     surface.Clear (BackgroundColor);
     foreach (Entity e in Entities)
         e._Draw (surface);
 }
开发者ID:Phyxius,项目名称:SomeZombieGame,代码行数:10,代码来源:EntityManager.cs

示例3: Draw

        public static void Draw(RenderTarget RT)
        {
            if (States.Count > 0)
                States.Peek().Draw(Screen);
            Screen.Display();

            RT.Clear(Color.Transparent);
            RT.Draw(Screen);
            if (Program.Debug)
                RT.Draw(FPSLabel);
        }
开发者ID:cartman300,项目名称:Tetraquark,代码行数:11,代码来源:Renderer.cs

示例4: Draw

        public override void Draw(RenderTarget target, RenderStates states)
        {
            target.Clear(Color.Black);

            target.SetView(_view);

            _game._mouseLight.SetPosition(target.MapPixelToCoords(InputHandler.MousePosition));
            _game.Map.Draw(target, states);
            if (_fpsToggle)
                _msFLabel.Draw(target, states);
        }
开发者ID:Tetramputechture,项目名称:Ending_0.1b,代码行数:11,代码来源:GameScreen.cs

示例5: Render

        public void Render(RenderTarget app) {
            if (!initalized) Init(app);
            app.Clear(Color.Transparent);

            world = CalcView(app);

            app.SetView(world);
            level.Draw(app, RenderStates.Default);
            foreach (GameObject o in objects) o.Draw(this, app, RenderStates.Default);
            player.Draw(app, RenderStates.Default);

            app.SetView(gui);
            infoText.Draw(app, RenderStates.Default);

            app.SetView(world);

            frames.Tick();
			InfoText = $"FPS: {frames.CurrentRate}, PSS: {physics.CurrentRate}";
        }
开发者ID:tilpner,项目名称:hp,代码行数:19,代码来源:Game.cs

示例6: Render

 public void Render(TimeSpan delta, RenderTarget target, UISceneManager ui)
 {
     target.Clear(Colors.White);
     particles.Render(particleTexture, particle);
     bg.Texture = particleTexture.Texture;
     bg.Color = new Color(150, 150, 150, 150);
     target.Draw(bg);
     ui.CurrentScene = scene;
 }
开发者ID:WebFreak001,项目名称:LD-30,代码行数:9,代码来源:MainMenuView.cs

示例7: RenderScene

        /// <summary>
        /// Renders the scene to the given render target.
        /// Clears the scene, then draws all shapes
        /// </summary>
        /// <param name="renderTarget">The render target.</param>
        private void RenderScene(RenderTarget renderTarget)
        {
            Cursor c = null;
            if (renderMode != RenderModes.HwndRenderTarget)
            {
                c = Cursor;
                Cursor = Cursors.WaitCursor;
            }
            renderTarget.BeginDraw();
            renderTarget.Clear(BackColorF);

            for (int i = 0; i < drawingShapes.Count; i++)
            {
                DrawingShape shape = drawingShapes[i];
                //tag with shape index for debugging
                renderTarget.Tags = new Tags((ulong)i, 0);
                shape.Draw(renderTarget);
            }
            Tags tags;
            ErrorCode errorCode;
            if (!renderTarget.TryEndDraw(out tags, out errorCode))
            {
                Debug.WriteLine(String.Format("Failed EndDraw. Error: {0}, tag1: {1}, tag2: {2}, shape[{1}]: {3}",
                    errorCode, tags.Tag1, tags.Tag2,
                    (int)tags.Tag1 < drawingShapes.Count ? drawingShapes[(int)tags.Tag1].ToString() : "<none>"));
            }
            if (renderMode != RenderModes.HwndRenderTarget)
                Cursor = c;
        }
开发者ID:QuocHuy7a10,项目名称:Arianrhod,代码行数:34,代码来源:D2DShapesControl.cs

示例8: RenderBegin

		private static void RenderBegin(RenderTarget renderTarget)
		{
			renderTarget.BeginDraw();
			renderTarget.Transform = Matrix3x2.Identity;
			renderTarget.Clear(new Color4(1.0f, 1.0f, 1.0f));
		}
开发者ID:zhandb,项目名称:slimdx,代码行数:6,代码来源:HelloWorldSample.cs

示例9: Render

        public void Render(RenderTarget gfx)
        {
            {
                var binWidth = (uint) Math.Pow(2, (int) Math.Ceiling(Math.Log(this.simView.Width, 2)));
                var binHeight = (uint) Math.Pow(2, (int) Math.Ceiling(Math.Log(this.simView.Height, 2)));

                if (binWidth != this.simTex.Size.X || binHeight != this.simTex.Size.Y) {
                    this.simTex = new RenderTexture(binWidth, binHeight);
                }
            }

            this.sim.Update();

            {
                this.simTex.Clear(this.BgColor);

                this.simView.Render(this.simTex);

                this.simTex.Display();
            }

            gfx.Clear(this.BgColor);

            {
                var simSprite = new Sprite(this.simTex.Texture);

                var posX = (int) (gfx.Size.X / 2 - (this.simView.LocalCursorPos.X + this.CellSize / 2) * this.Zoom);
                var posY = (int) (gfx.Size.Y / 2 - (this.simView.LocalCursorPos.Y + this.CellSize / 2) * this.Zoom);
                simSprite.Position = new Vector2f(posX, posY);

                if (Math.Abs(this.Zoom - 1f) > .1f) {
                    simSprite.Scale = new Vector2f(this.Zoom, this.Zoom);
                }

                gfx.Draw(simSprite);
            }

            if (this.showHelp) {
                this.helpOverlay.Render(gfx);
            } else {
                this.helpLastSimState = this.sim.IsRunning;

                {
                    this.menuBg.Size = new Vector2f(gfx.Size.X, 20);
                    gfx.Draw(this.menuBg);
                }
                gfx.Draw(this.helpText);
            }

            {
                this.simStateText.DisplayedString = String.Format("[ {0} ]", (this.sim.IsRunning ? "RUNNING" : "PAUSED"));
                var x = (int) (gfx.Size.X - this.simStateText.GetLocalBounds().Width) / 2;
                this.simStateText.Position = new Vector2f(x, 2);
                gfx.Draw(this.simStateText);
            }

            {
                this.fpsText.DisplayedString = String.Format(
                    "FPS: {0:F1}",
                    this.wnd.FPSGauge.FPS);
                var x = gfx.Size.X - this.fpsText.GetLocalBounds().Width - 5;
                this.fpsText.Position = new Vector2f(x, 2);
                gfx.Draw(this.fpsText);
            }
        }
开发者ID:mkaput,项目名称:GameOfLifes-net,代码行数:65,代码来源:SimulationScene.cs

示例10: Paint

        public void Paint(RenderTarget target)
        {
            target.BeginDraw();
            target.Transform = Matrix3x2.Identity;
            if (Fancy)
                target.FillRectangle(BackgroundGradient, new RectangleF(PointF.Empty, target.Size));
            else
                target.Clear(Color.Black);
            #region draw_notes
            lock (notes)
            {
                foreach (Note n in notes)
                {
                    float wheelOffset = (Keyboard.Pitchwheel[n.Channel] - 8192) / 8192f * 2 * KeyWidth;
                    float bottom = n.Position + n.Length;
                    float left = n.Key * KeyWidth + (bottom >= KeyboardY ? wheelOffset : 0);
                    if (Fancy)
                    {
                        NoteRoundRect.Left = left;
                        NoteRoundRect.Top = n.Position;
                        NoteRoundRect.Right = left + KeyWidth;
                        NoteRoundRect.Bottom = bottom;

                        float alpha = n.Velocity / 127f * (Keyboard.ChannelVolume[n.Channel] / 127f);
                        alpha *= alpha;
                        var gradientBrush = ChannelGradientBrushes[n.Channel];
                        gradientBrush.Opacity = alpha;
                        GradientPoint.X = NoteRoundRect.Left;
                        gradientBrush.StartPoint = GradientPoint;
                        GradientPoint.X = NoteRoundRect.Right;
                        gradientBrush.EndPoint = GradientPoint;
                        target.FillRoundedRectangle(ChannelGradientBrushes[n.Channel], NoteRoundRect);
                    }
                    else
                    {
                        NoteRect.X = left;
                        NoteRect.Y = n.Position;
                        NoteRect.Width = KeyWidth;
                        NoteRect.Height = n.Length;
                        target.FillRectangle(ChannelBrushes[n.Channel], NoteRect);
                    }
                }
            }
            #endregion

            Keyboard.Render(target);

            // Draw time progress bar
            if (sequence?.GetLength() > 0)
            {
                float percentComplete = 1f*sequencer.Position/sequence.GetLength();
                target.FillRectangle(DefaultBrushes[5],
                    new RectangleF(ProgressBarBounds.X, ProgressBarBounds.Y, ProgressBarBounds.Width*percentComplete, ProgressBarBounds.Height));
                target.DrawRectangle(DefaultBrushes[2], ProgressBarBounds, .8f);
            }


            string[] debug =
            {
                "      file: " + MIDIFile,
                "note_count: " + notes.Count,
                "  renderer: " + (Fancy ? "fancy" : UserFancy ? "forced-fast" : "fast"),
                "      note: " + (sequence == null ? "? / ?" : sequencer.Position + " / " + sequence.GetLength()),
                "     delay: " + Delay
            };
            string debugText = debug.Aggregate("", (current, ss) => current + ss + '\n');
            target.DrawText(debugText, DebugFormat, DebugRectangle, DefaultBrushes[0], DrawTextOptions.None, MeasuringMethod.Natural);

            if (Loading == 0)
                target.DrawText("INITIALIZING MIDI DEVICES", HugeFormat, FullRectangle, DefaultBrushes[0], DrawTextOptions.None, MeasuringMethod.Natural);
            else if (Loading > 0)
                target.DrawText("LOADING " + Loading + "%", HugeFormat, FullRectangle, DefaultBrushes[0], DrawTextOptions.None, MeasuringMethod.Natural);
            target.EndDraw();
        }
开发者ID:HuYang719,项目名称:MIDITrailer,代码行数:74,代码来源:MIDITrailer.cs

示例11: Draw

        public void Draw(RenderTarget t)
        {
            t.Clear(new Color(65, 64, 60));

            btnAddRoom.Draw(t, cursorMode == CursorMode.AddRoom);
            btnAddDoor.Draw(t, cursorMode == CursorMode.AddDoor);
            //btnLoad.Draw(t, false);
            btnLoadBase.Draw(t, false);
            btnLoadFloor.Draw(t, false);
            btnOptions.Draw(t, false);

            if (BaseTex != null)
                btnToggleBase.Draw(t, drawBase);
            if (FloorTex != null)
                btnToggleFloor.Draw(t, drawFloor);

            if (BaseTex != null || FloorTex != null)
                btnMoveBG.Draw(t, cursorMode == CursorMode.PlaceBGCursor || cursorMode == CursorMode.PlacedBGCursor);

            btnMoveGibs.Draw(t, cursorMode == CursorMode.PlaceGibsCursor || cursorMode == CursorMode.PlacedGibsCursor);

            placeRoomCloaking.Draw(t, false);
            placeRoomDoors.Draw(t, false);
            placeRoomDrones.Draw(t, false);
            placeRoomEngines.Draw(t, false);
            placeRoomMedbay.Draw(t, false);
            placeRoomOxygen.Draw(t, false);
            placeRoomPilot.Draw(t, false);
            placeRoomSensors.Draw(t, false);
            placeRoomShields.Draw(t, false);
            placeRoomTeleporter.Draw(t, false);
            placeRoomWeapons.Draw(t, false);
            if (BaseTex != null && drawBase)
            {
                BaseTex.Position = bgOffset + (new Vector2f(Game.ship.LayoutData.X_OFFSET, Game.ship.LayoutData.Y_OFFSET) * 35);
                BaseTex.Draw(t, RenderStates.Default);
            }
            if (FloorTex != null && drawFloor)
            {
                FloorTex.Position = bgOffset + (new Vector2f(Game.ship.LayoutData.X_OFFSET, Game.ship.LayoutData.Y_OFFSET) * 35);
                FloorTex.Draw(t, RenderStates.Default);
            }

            // Draw grid
            foreach (FTLRoom room in ShipRooms)
                t.Draw(room.drawer);
            foreach (FTLDoor door in ShipDoors)
                t.Draw(door.drawer);

            for (int currentY = 1; currentY < 600; currentY += 35)
            {
                verts[0].Position = new Vector2f(0, currentY);
                verts[1].Position = new Vector2f(GUIStartX, currentY);
                t.Draw(verts, PrimitiveType.Lines);
            }
            for (int currentX = 0; currentX < GUIStartX; currentX += 35)
            {
                verts[0].Position = new Vector2f(currentX, 0);
                verts[1].Position = new Vector2f(currentX, 600);
                t.Draw(verts, PrimitiveType.Lines);
            }

            if (ship != null)
                foreach (RoomFunc rf in ship.rooms.Values)
                {
                    if (rf == null || rf.location == null)
                        continue;
                    Sprite temp = new Sprite(rf.image);
                    temp.Position = new Vector2f((rf.location.position.X + (((float)rf.location.size.X - 1) / 2)) * 35, (rf.location.position.Y + (((float)rf.location.size.Y - 1) / 2)) * 35);
                    temp.Position += (new Vector2f(Game.ship.LayoutData.X_OFFSET, Game.ship.LayoutData.Y_OFFSET) * 35);
                    t.Draw(temp);
                    temp.Dispose();
                }

            ViewOffsetter.Draw(t, rs);

            if (cursorMode == CursorMode.AddDoor)
            {
                RectangleShape curDoor;
                if (DoorHorizontal)
                {
                    curDoor = new RectangleShape(new Vector2f(19, 4));
                    curDoor.Position = new Vector2f((SFML.Window.Mouse.GetPosition(Program.app).X / 35) * 35 + 7, (SFML.Window.Mouse.GetPosition(Program.app).Y / 35) * 35 - 2);

                }
                else
                {
                    curDoor = new RectangleShape(new Vector2f(4, 19));
                    curDoor.Position = new Vector2f((SFML.Window.Mouse.GetPosition(Program.app).X / 35) * 35 - 2, (SFML.Window.Mouse.GetPosition(Program.app).Y / 35) * 35 + 7);
                }
                curDoor.FillColor = new Color(255, 150, 50);
                curDoor.OutlineColor = new Color(0, 0, 0);
                curDoor.OutlineThickness = 1;
                t.Draw(curDoor);
                curDoor.Dispose();

            }

            if (cursorMode == CursorMode.AddRoom)
            {
//.........这里部分代码省略.........
开发者ID:nyteshade,项目名称:FTLEdit,代码行数:101,代码来源:Game.cs

示例12: Render

        public void Render(RenderTarget target)
        {
            // Fill background depending on render mode
            if (NoteManager.RenderFancy)
                target.FillRectangle(GFXResources.BackgroundGradient, new RectangleF(PointF.Empty, target.Size));
            else
                target.Clear(Color.Black);

            // Render notes and keyboard display
            lock (NoteManager.Notes)
            {
                if (NoteManager.RenderFancy)
                    NoteRenderers[1].Render(target, NoteManager.Notes, Keyboard);
                else
                    NoteRenderers[0].Render(target, NoteManager.Notes, Keyboard);
            }
            lock (Keyboard.KeyPressed)
            {
                if (NoteManager.RenderFancy)
                    KeyRenderers[1].Render(target, Keyboard.KeyPressed);
                else
                    KeyRenderers[0].Render(target, Keyboard.KeyPressed);
            }

            // Draw time progress bar
            if (sequence?.GetLength() > 0)
            {
                float percentComplete = 1f * sequencer.Position / sequence.GetLength();
                target.FillRectangle(GFXResources.DefaultBrushes[5],
                    new RectangleF(GFXResources.ProgressBarBounds.X, GFXResources.ProgressBarBounds.Y, GFXResources.ProgressBarBounds.Width * percentComplete, GFXResources.ProgressBarBounds.Height));
                target.DrawRectangle(GFXResources.DefaultBrushes[2], GFXResources.ProgressBarBounds, .8f);
            }

            // Render debug information
            string[] debug;
            string usage = Application.ProductName + " " + Application.ProductVersion + " (c) " + Application.CompanyName;
            if (ShowDebug)
            {
                debug = new[]
                {
                    usage,
                    "      file: " + MIDIFile,
                    "note_count: " + NoteManager.Notes.Count,
                    "  frames/s: " + (Kazedan.Elapsed == 0 ? "NaN" : 1000 / Kazedan.Elapsed + "") +" fps",
                    "  renderer: " + (NoteManager.RenderFancy ? "fancy" : NoteManager.UserEnabledFancy ? "forced-fast" : "fast"),
                    "  seq_tick: " + (sequence == null ? "? / ?" : sequencer.Position + " / " + sequence.GetLength()),
                    "     delay: " + Delay+"ms",
                    "       kbd: " + GFXResources.NoteCount + " key(s) +" + GFXResources.NoteOffset + " offset",
                    "   stopped: " + Stopped
                };

            }
            else
            {
                debug = new[] { usage };
            }
            string debugText = debug.Aggregate("", (current, ss) => current + ss + '\n');
            target.DrawText(debugText, GFXResources.DebugFormat, GFXResources.DebugRectangle, GFXResources.DefaultBrushes[0], DrawTextOptions.None,
                MeasuringMethod.Natural);

            // Render large title text
            if (Loading == 0)
                target.DrawText("INITIALIZING MIDI DEVICES", GFXResources.HugeFormat, GFXResources.FullRectangle, GFXResources.DefaultBrushes[0], DrawTextOptions.None, MeasuringMethod.Natural);
            else if (Loading > 0 && Loading < 100)
                target.DrawText("LOADING " + Loading + "%", GFXResources.HugeFormat, GFXResources.FullRectangle, GFXResources.DefaultBrushes[0], DrawTextOptions.None, MeasuringMethod.Natural);
        }
开发者ID:Netdex,项目名称:Kazedan,代码行数:66,代码来源:MIDISequencer.cs


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