• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IDrawDevice类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IDrawDevice的典型用法代码示例。如果您正苦于以下问题:C# IDrawDevice类的具体用法?C# IDrawDevice怎么用?C# IDrawDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IDrawDevice类属于命名空间,在下文中一共展示了IDrawDevice类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Draw

		public override void Draw(IDrawDevice device)
		{
			// Perform Camera space transformation
			Vector3 posBefore = this.GameObj.Transform.Pos;
			Vector3 posTemp = posBefore;
			float scaleTemp = 1.0f;
			device.PreprocessCoords(this, ref posTemp, ref scaleTemp);

			// Draw debug text
			VertexC1P3T2[] textVertices;
			textVertices = null;
			Font.GenericMonospace10.Res.EmitTextVertices(
				string.Format("Position (world): {0:0}, {1:0}, {2:0}", posBefore.X, posBefore.Y, posBefore.Z),
				ref textVertices, posTemp.X, posTemp.Y, posTemp.Z);
			device.AddVertices(Font.GenericMonospace10.Res.Material, BeginMode.Quads, textVertices);

			textVertices = null;
			Font.GenericMonospace10.Res.EmitTextVertices(
				string.Format("Position (cam): {0:0}, {1:0}, {2:0}", posTemp.X, posTemp.Y, posTemp.Z),
				ref textVertices, posTemp.X, posTemp.Y + 10, posTemp.Z);
			device.AddVertices(Font.GenericMonospace10.Res.Material, BeginMode.Quads, textVertices);

			textVertices = null;
			Font.GenericMonospace10.Res.EmitTextVertices(
				string.Format("Scale: {0:F}", scaleTemp),
				ref textVertices, posTemp.X, posTemp.Y + 20, posTemp.Z);
			device.AddVertices(Font.GenericMonospace10.Res.Material, BeginMode.Quads, textVertices);

			// Draw position indicator
			device.AddVertices(new BatchInfo(DrawTechnique.Alpha, ColorRgba.Red.WithAlpha(0.25f)), BeginMode.Quads, new VertexP3[] {
				new VertexP3(posTemp.X - 50.0f * scaleTemp, posTemp.Y - 50.0f * scaleTemp, posTemp.Z),
				new VertexP3(posTemp.X + 50.0f * scaleTemp, posTemp.Y - 50.0f * scaleTemp, posTemp.Z),
				new VertexP3(posTemp.X + 50.0f * scaleTemp, posTemp.Y + 50.0f * scaleTemp, posTemp.Z),
				new VertexP3(posTemp.X - 50.0f * scaleTemp, posTemp.Y + 50.0f * scaleTemp, posTemp.Z) });
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:35,代码来源:DebugObject.cs


示例2: Draw

        public override void Draw(IDrawDevice device)
        {
            var mainClr = RetrieveMainColor();

            PrepareVertices(device, mainClr);
            device.AddVertices(sharedMat, VertexMode.Quads, _vertices);
        }
开发者ID:BraveSirAndrew,项目名称:DublinGamecraft4,代码行数:7,代码来源:SnowSkirt.cs


示例3: QueryVisibleRenderers

 public IEnumerable<ICmpRenderer> QueryVisibleRenderers(IDrawDevice device)
 {
     if (this.renderers == null)
         return Enumerable.Empty<ICmpRenderer>();
     else
         return this.renderers.Where(r => (r as Component).Active && r.IsVisible(device));
 }
开发者ID:ninja2003,项目名称:duality,代码行数:7,代码来源:DefaultRendererVisibilityStrategy.cs


示例4: TryGetValue

		/// <summary>
		/// Retrieves the value of a builtin shader variable using the index retrieved by <see cref="GetIndex"/>.
		/// </summary>
		/// <param name="currentDevice"></param>
		/// <param name="index"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static bool TryGetValue(IDrawDevice currentDevice, int index, ref float[] value)
		{
			int size = 1;
			switch (index)
			{
				case InvalidIndex: return false;
				default: size = 1; break;
				case 4:  size = 3; break;
			}

			value = (value != null && value.Length == size) ? value : new float[size];
			switch (index)
			{
				case 0: value[0] = (float)Time.MainTimer.TotalSeconds; return true;
				case 1: value[0] = (float)Time.GameTimer.TotalSeconds; return true;
				case 2: value[0] = (float)Time.FrameCount;             return true;
				case 3: value[0] = currentDevice.FocusDist;            return true;
				case 4: value[0] = currentDevice.RefCoord.X;
				        value[1] = currentDevice.RefCoord.Y;
				        value[2] = currentDevice.RefCoord.Z;           return true;
				case 5: value[0] = currentDevice.Perspective == PerspectiveMode.Parallax ? 1.0f : 0.0f; return true;
			}

			return false;
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:32,代码来源:BuiltinShaderFields.cs


示例5: QueryVisibleRenderers

		public void QueryVisibleRenderers(IDrawDevice device, RawList<ICmpRenderer> targetList)
		{
			// Empty the cached list of visible renderers
			targetList.Count = 0;
			targetList.Reserve(this.totalRendererCount);

			// Copy references to all renderers that are visible to the target device
			int visibleCount = 0;
			ICmpRenderer[] targetData = targetList.Data;
			foreach (var pair in this.renderersByType)
			{
				ICmpRenderer[] data = pair.Value.Data;
				for (int i = 0; i < data.Length; i++)
				{
					if (i >= pair.Value.Count) break;

					if ((data[i] as Component).Active && data[i].IsVisible(device))
					{
						targetData[visibleCount] = data[i];
						visibleCount++;
					}
				}
			}
			targetList.Count = visibleCount;
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:25,代码来源:DefaultRendererVisibilityStrategy.cs


示例6:

		bool ICmpRenderer.IsVisible(IDrawDevice device)
		{
			// Only render when in screen overlay mode and the visibility mask is non-empty.
			return 
				(device.VisibilityMask & VisibilityFlag.AllGroups) != VisibilityFlag.None &&
				(device.VisibilityMask & VisibilityFlag.ScreenOverlay) != VisibilityFlag.None;
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:7,代码来源:GameOverScreen.cs


示例7: Draw

        public override void Draw(IDrawDevice device)
        {
            Texture mainTex = this.RetrieveMainTex();
            ColorRgba mainClr = this.RetrieveMainColor();
            DrawTechnique tech = this.RetrieveDrawTechnique();

            Rect uvRect;
            if (mainTex != null)
            {
                if (this.rectMode == UVMode.WrapBoth)
                    uvRect = new Rect(mainTex.UVRatio.X * this.rect.W / mainTex.PixelWidth, mainTex.UVRatio.Y * this.rect.H / mainTex.PixelHeight);
                else if (this.rectMode == UVMode.WrapHorizontal)
                    uvRect = new Rect(mainTex.UVRatio.X * this.rect.W / mainTex.PixelWidth, mainTex.UVRatio.Y);
                else if (this.rectMode == UVMode.WrapVertical)
                    uvRect = new Rect(mainTex.UVRatio.X, mainTex.UVRatio.Y * this.rect.H / mainTex.PixelHeight);
                else
                    uvRect = new Rect(mainTex.UVRatio.X, mainTex.UVRatio.Y);
            }
            else
                uvRect = new Rect(1.0f, 1.0f);

            this.PrepareVerticesLight(ref this.verticesLight, device, mainClr, uvRect, tech);

            if (this.customMat != null)	device.AddVertices(this.customMat, VertexMode.Quads, this.verticesLight);
            else						device.AddVertices(this.sharedMat, VertexMode.Quads, this.verticesLight);
        }
开发者ID:SirePi,项目名称:duality,代码行数:26,代码来源:LightingSpriteRenderer.cs


示例8: IsVisible

 public bool IsVisible(IDrawDevice device)
 {
     return
     // Make sure the ScreenOverlay flag is set
     (device.VisibilityMask & VisibilityFlag.ScreenOverlay) != VisibilityFlag.None &&
     // Make sure some other flag is also set.
     (device.VisibilityMask & ~VisibilityFlag.ScreenOverlay) != VisibilityFlag.None;
 }
开发者ID:generatives,项目名称:Magic-Game,代码行数:8,代码来源:UIManager.cs


示例9: PrepareRendering

		protected override void PrepareRendering(IDrawDevice device, BatchInfo material)
		{
			base.PrepareRendering(device, material);

			material.SetTexture("mainTex", TextureOne);
			material.SetTexture("samp1", TextureTwo);
			material.SetTexture("samp2", TextureThree);
		}
开发者ID:Narinyir,项目名称:DualityOgvPlayerPlugin,代码行数:8,代码来源:OgvDrawTechnique.cs


示例10: Canvas

        void ICmpRenderer.Draw(IDrawDevice device)
        {
            if (device.VisibilityMask.HasFlag(VisibilityFlag.ScreenOverlay))
            {
                Canvas target = new Canvas(device, this.vertexBufferScreen);
                target.State.SetMaterial(new BatchInfo(DrawTechnique.Alpha, ColorRgba.White));
                foreach (VisualLog log in VisualLog.All)
                {
                    if (!log.Visible) continue;
                    if (log.BaseColor.A == 0) continue;
                    if ((log.VisibilityGroup & device.VisibilityMask & VisibilityFlag.AllGroups) == VisibilityFlag.None) continue;

                    target.State.SetMaterial(new BatchInfo(DrawTechnique.Alpha, log.BaseColor));
                    foreach (VisualLogEntry logEntry in log.Entries)
                    {
                        if (logEntry.Anchor != VisualLogAnchor.Screen) continue;
                        target.PushState();
                        if (logEntry.LifetimeAsAlpha)
                            target.State.ColorTint = new ColorRgba(1.0f, logEntry.LifetimeRatio);
                        else
                            target.State.ColorTint = ColorRgba.White;
                        logEntry.Draw(target);
                        target.PopState();
                    }
                }
            }
            else
            {
                Canvas target = new Canvas(device, this.vertexBufferWorld);
                target.State.SetMaterial(new BatchInfo(DrawTechnique.Alpha, ColorRgba.White));
                target.State.ZOffset = -1;
                foreach (VisualLog log in VisualLog.All)
                {
                    if (!log.Visible) continue;
                    if (log.BaseColor.A == 0) continue;
                    if ((log.VisibilityGroup & device.VisibilityMask & VisibilityFlag.AllGroups) == VisibilityFlag.None) continue;

                    target.State.SetMaterial(new BatchInfo(DrawTechnique.Alpha, log.BaseColor));
                    foreach (VisualLogEntry logEntry in log.Entries)
                    {
                        if (logEntry.Anchor == VisualLogAnchor.Screen) continue;
                        target.PushState();
                        target.State.ZOffset += logEntry.DepthOffset;
                        target.State.ColorTint = new ColorRgba(1.0f, logEntry.LifetimeRatio);
                        if (logEntry.Anchor == VisualLogAnchor.Object && logEntry.AnchorObj != null && logEntry.AnchorObj.Transform != null)
                        {
                            Transform anchorTransform = logEntry.AnchorObj.Transform;
                            logEntry.Draw(target, anchorTransform.Pos, anchorTransform.Angle, anchorTransform.Scale);
                        }
                        else
                        {
                            logEntry.Draw(target);
                        }
                        target.PopState();
                    }
                }
            }
        }
开发者ID:SirePi,项目名称:duality,代码行数:58,代码来源:VisualLogRenderer.cs


示例11: Draw

 public void Draw(IDrawDevice device)
 {
     Canvas canvas = new Canvas(device);
     if(baseControl.NeedsLayout)
     {
         baseControl.Layout();
     }
     baseControl.Draw(canvas);
 }
开发者ID:generatives,项目名称:Magic-Game,代码行数:9,代码来源:UIManager.cs


示例12: PrepareRendering

        public override void PrepareRendering(IDrawDevice device, BatchInfo material)
        {
            base.PrepareRendering(device, material);

            Vector3 camPos = device.RefCoord;
            float camRefDist = MathF.Abs(device.FocusDist);

            // Don't pass RefDist, see note in Light.cs
            material.SetUniform("_camRefDist", camRefDist);
            material.SetUniform("_camWorldPos", camPos.X, camPos.Y, camPos.Z);

            DynamicLighting.Light.SetupLighting(device, material);
        }
开发者ID:gitMaxim,项目名称:duality,代码行数:13,代码来源:LightingTechnique.cs


示例13: GrabScreenshot

		public static Bitmap GrabScreenshot(IDrawDevice device)
		{
			if (GraphicsContext.CurrentContext == null)
				throw new GraphicsContextMissingException();

			var bmp = new Bitmap((int) device.TargetSize.X, (int)device.TargetSize.Y);
			var data = bmp.LockBits(new Rectangle(0, 0, (int) device.TargetSize.X, (int) device.TargetSize.Y), ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
			GL.ReadPixels(0, 0, (int) device.TargetSize.X, (int) device.TargetSize.Y, PixelFormat.Bgr, PixelType.UnsignedByte, data.Scan0);
			bmp.UnlockBits(data);

//			bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
			return bmp;
		}
开发者ID:Andrea,项目名称:duality-withsvn-history,代码行数:13,代码来源:GraphicsHelpers.cs


示例14: Canvas

		void ICmpRenderer.Draw(IDrawDevice device)
		{
			Canvas canvas = new Canvas(device);

			// Draw the mouse cursor when available
			if (DualityApp.Mouse.IsAvailable)
			{
				canvas.State.ColorTint = ColorRgba.White;
				canvas.FillCircle(
					DualityApp.Mouse.X, 
					DualityApp.Mouse.Y, 
					2);
			}
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:14,代码来源:MouseCursorRenderer.cs


示例15: Draw

        public void Draw(IDrawDevice device)
        {
            var triangles = env.Triangles;
            var triangleSideLength = env.TriangleSideLength;
            Canvas canvas = new Canvas(device);

            Vector2[][] vectors = new Vector2[4][];

            vectors[0] = new Vector2[3];
            vectors[0][0] = new Vector2(-(triangleSideLength / 2), -(triangleSideLength / 2));
            vectors[0][1] = new Vector2((triangleSideLength / 2), -(triangleSideLength / 2));
            vectors[0][2] = new Vector2(0, 0);

            vectors[1] = new Vector2[3];
            vectors[1][0] = new Vector2((triangleSideLength / 2), -(triangleSideLength / 2));
            vectors[1][1] = new Vector2((triangleSideLength / 2), (triangleSideLength / 2));
            vectors[1][2] = new Vector2(0, 0);

            vectors[2] = new Vector2[3];
            vectors[2][0] = new Vector2((triangleSideLength / 2), (triangleSideLength / 2));
            vectors[2][1] = new Vector2(-(triangleSideLength / 2), (triangleSideLength / 2));
            vectors[2][2] = new Vector2(0, 0);

            vectors[3] = new Vector2[3];
            vectors[3][0] = new Vector2(-(triangleSideLength / 2), (triangleSideLength / 2));
            vectors[3][1] = new Vector2(-(triangleSideLength / 2), -(triangleSideLength / 2));
            vectors[3][2] = new Vector2(0, 0);

            BatchInfo[] infos = new BatchInfo[4];
            infos[0] = new BatchInfo(DrawTechnique.Alpha, ColorRgba.Red, null);
            infos[1] = new BatchInfo(DrawTechnique.Alpha, ColorRgba.Blue, null);
            infos[2] = new BatchInfo(DrawTechnique.Alpha, ColorRgba.White, null);
            infos[3] = new BatchInfo(DrawTechnique.Alpha, ColorRgba.Green, null);
            for (int x = 0; x < triangles.GetLength(0); x++)
            {
                for (int y = 0; y < triangles.GetLength(1); y++)
                {
                    for (int i = 0; i < triangles.GetLength(2); i++)
                    {
                        canvas.State.SetMaterial(infos[i]);
                        if(true/*triangles[x,y,i] != null*/)
                        {
                            canvas.FillPolygon(vectors[i], triangleSideLength / 2 + triangleSideLength * x,
                            triangleSideLength / 2 + triangleSideLength * y);
                        }
                    }
                }
            }
        }
开发者ID:generatives,项目名称:Magic-Game,代码行数:49,代码来源:EnvironmentRenderer.cs


示例16: IsVisible

 public bool IsVisible(IDrawDevice device)
 {
     // Differing ScreenOverlay flag? Don't render!
     if ((device.VisibilityMask & VisibilityFlag.ScreenOverlay) != (this.visibilityGroup & VisibilityFlag.ScreenOverlay))
     {
         return false;
     }
     // No match in any VisibilityGroup? Don't render!
     if ((this.visibilityGroup & device.VisibilityMask & VisibilityFlag.AllGroups) == VisibilityFlag.None)
     {
         return false;
     }
     // (Culling:) Not located near the screen? Don't render!
     return true;
 }
开发者ID:generatives,项目名称:Magic-Game,代码行数:15,代码来源:EnvironmentRenderer.cs


示例17: Canvas

		void ICmpRenderer.Draw(IDrawDevice device)
		{
			Canvas canvas = new Canvas(device);
			
			// Update input stats texts for drawing
			this.WriteInputStats(ref this.mouseStatsText, DualityApp.Mouse);
			this.WriteInputStats(ref this.keyboardStatsText, DualityApp.Keyboard);
			this.WriteInputStats(ref this.joystickStatsText, DualityApp.Joysticks);
			this.WriteInputStats(ref this.gamepadStatsText, DualityApp.Gamepads);

			// Draw input stats texts
			{
				int y = 10;

				canvas.DrawText(this.mouseStatsText, 10, y, 0, null, Alignment.TopLeft, true);
				y += 20 + (int)this.mouseStatsText.TextMetrics.Size.Y;

				canvas.DrawText(this.keyboardStatsText, 10, y, 0, null, Alignment.TopLeft, true);
				y += 20 + (int)this.keyboardStatsText.TextMetrics.Size.Y;

				canvas.DrawText(this.joystickStatsText, 10, y, 0, null, Alignment.TopLeft, true);
				y += 20 + (int)this.joystickStatsText.TextMetrics.Size.Y;

				canvas.DrawText(this.gamepadStatsText, 10, y, 0, null, Alignment.TopLeft, true);
				y += 20 + (int)this.gamepadStatsText.TextMetrics.Size.Y;
			}

			// Draw the mouse cursor's movement trail
			if (DualityApp.Mouse.IsAvailable)
			{
				canvas.State.ColorTint = new ColorRgba(128, 192, 255, 128);
				canvas.FillThickLine(
					DualityApp.Mouse.X - DualityApp.Mouse.XSpeed, 
					DualityApp.Mouse.Y - DualityApp.Mouse.YSpeed, 
					DualityApp.Mouse.X, 
					DualityApp.Mouse.Y, 
					2);
				// Draw the mouse cursor at its local window coordiates
				canvas.State.ColorTint = ColorRgba.White;
				canvas.FillCircle(
					DualityApp.Mouse.X, 
					DualityApp.Mouse.Y, 
					2);
			}
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:45,代码来源:InputMonitor.cs


示例18: Canvas

		void ICmpRenderer.Draw(IDrawDevice device)
		{
			Canvas canvas = new Canvas(device);

			if (device.IsScreenOverlay)
			{
				// Testbed text
				Vector2 nameSize = this.name.Measure().Size;
				Vector2 descSize = this.desc.Measure().Size;
				Vector2 ctrlSize = this.controls.Measure().Size;
				Vector2 statsSize = this.stats.Measure().Size;
				canvas.PushState();
				// Text background
				canvas.CurrentState.SetMaterial(new BatchInfo(DrawTechnique.Alpha, ColorRgba.White));
				canvas.CurrentState.ColorTint = ColorRgba.Black.WithAlpha(0.5f);
				canvas.FillRect(10, 10, MathF.Max(nameSize.X, descSize.X, ctrlSize.X) + 20, nameSize.Y + descSize.Y + 10 + ctrlSize.Y + 10);
				canvas.FillRect(10, DualityApp.TargetResolution.Y - 20 - statsSize.Y, statsSize.X + 20, statsSize.Y + 10);
				// Caption / Name
				canvas.CurrentState.ColorTint = ColorRgba.White.WithAlpha(0.85f);
				canvas.DrawText(this.name, 20, 15);
				// Description, Controls, Stats
				canvas.CurrentState.ColorTint = ColorRgba.White.WithAlpha(0.65f);
				canvas.DrawText(this.desc, 20, 15 + nameSize.Y);
				canvas.DrawText(this.controls, 20, 15 + nameSize.Y + descSize.Y + 10);
				canvas.DrawText(this.stats, 20, DualityApp.TargetResolution.Y - 15 - statsSize.Y);
				canvas.PopState();

				// Mouse cursor
				canvas.DrawCross(DualityApp.Mouse.X, DualityApp.Mouse.Y, 5.0f);
			}
			else
			{
				// Mouse joint, if existing
				if (this.mouseJoint != null)
				{
					Vector3 jointBegin = this.mouseJoint.BodyA.GameObj.Transform.GetWorldPoint(new Vector3(this.mouseJoint.LocalAnchor, -0.01f));
					Vector3 jointEnd = new Vector3(this.mouseJoint.WorldAnchor, -0.01f);
					canvas.CurrentState.ColorTint = ColorRgba.Red.WithAlpha(0.5f);
					canvas.DrawLine(jointBegin.X, jointBegin.Y, jointBegin.Z, jointEnd.X, jointEnd.Y, jointEnd.Z);
				}
			}
		}
开发者ID:Andrea,项目名称:duality-withsvn-history,代码行数:42,代码来源:Testbed.cs


示例19: Draw

        public override void Draw(IDrawDevice device)
        {
            Texture mainTex = this.RetrieveMainTex();
            ColorRgba mainClr = this.RetrieveMainColor();
            DrawTechnique tech = this.RetrieveDrawTechnique();

            Rect uvRect;
            Rect uvRectNext;
            bool smoothShaderInput = tech != null && tech.PreferredVertexFormat == VertexC1P3T4A4A1.Declaration;
            this.GetAnimData(mainTex, tech, smoothShaderInput, out uvRect, out uvRectNext);

            if (!smoothShaderInput)
            {
                this.PrepareVerticesLight(ref this.verticesLight, device, mainClr, uvRect, tech);
                if (this.customMat != null)	device.AddVertices(this.customMat, VertexMode.Quads, this.verticesLight);
                else						device.AddVertices(this.sharedMat, VertexMode.Quads, this.verticesLight);
            }
            else
            {
                this.PrepareVerticesLightSmooth(ref this.verticesLightSmooth, device, this.CurrentFrameProgress, mainClr, uvRect, uvRectNext, tech);
                if (this.customMat != null)	device.AddVertices(this.customMat, VertexMode.Quads, this.verticesLightSmooth);
                else						device.AddVertices(this.sharedMat, VertexMode.Quads, this.verticesLightSmooth);
            }
        }
开发者ID:gitMaxim,项目名称:duality,代码行数:24,代码来源:LightingAnimSpriteRenderer.cs


示例20: if

		void ICmpRenderer.Draw(IDrawDevice device)
		{
			Profile.BeginMeasure(@"ProfileRenderer");
			Canvas canvas = new Canvas(device);
			canvas.CurrentState.SetMaterial(new BatchInfo(DrawTechnique.Alpha, ColorRgba.White, null));
			
			bool anyTextReport = this.textReportPerf || this.textReportStat;
			bool anyGraph = this.drawGraphs && this.counterGraphs.Count > 0;

			// Determine geometry
			int areaWidth = (int)device.TargetSize.X - 20;
			if (anyGraph && anyTextReport)
				areaWidth = (areaWidth - 10) / 2;
			Rect textReportRect = new Rect(
				10, 
				10, 
				anyTextReport ? areaWidth : 0, 
				(int)device.TargetSize.Y - 20);
			Rect graphRect = new Rect(
				anyTextReport ? (textReportRect.MaximumX + 10) : 10, 
				10, 
				anyGraph ? areaWidth : 0, 
				(int)device.TargetSize.Y - 20);

			// Text Reports
			if (anyTextReport)
			{
				// Update Report
				IEnumerable<ProfileCounter> counters = Profile.GetUsedCounters();
				if (!this.textReportPerf) counters = counters.Where(c => !(c is TimeCounter));
				if (!this.textReportStat) counters = counters.Where(c => !(c is StatCounter));
				if (this.textReport == null || (Time.MainTimer - this.textReportLast).TotalMilliseconds > this.updateInterval)
				{
					string report = Profile.GetTextReport(counters, this.textReportOptions | ReportOptions.FormattedText);

					if (this.textReport == null)
					{
						this.textReport = new FormattedText();
						this.textReport.Fonts = new[] { Font.GenericMonospace8 };
					}
					this.textReport.MaxWidth = (int)textReportRect.W;
					this.textReport.SourceText = report;
					this.textReportLast = Time.MainTimer;
				}

				// Draw Report
				canvas.DrawTextBackground(textReport, textReportRect.X, textReportRect.Y);
				canvas.DrawText(textReport, ref textReportTextVert, ref textReportIconVert, textReportRect.X, textReportRect.Y);
			}

			// Counter Graphs
			if (anyGraph)
			{
				// Mark graph cache as unused
				foreach (GraphCacheEntry entry in this.graphCache.Values)
				{
					entry.WasUsed = false;
				}

				int space = 5;
				int graphY = (int)graphRect.Y;
				int graphH = MathF.Min((int)(graphRect.H / this.counterGraphs.Count) - space, (int)graphRect.W / 2);
				foreach (string counterName in this.counterGraphs)
				{
					ProfileCounter counter = Profile.GetCounter<ProfileCounter>(counterName);
					if (counter == null) return;

					// Create or retrieve graph cache entry
					GraphCacheEntry cache = null;
					if (!this.graphCache.TryGetValue(counterName, out cache))
					{
						cache = new GraphCacheEntry();
						cache.GraphValues = new float[ProfileCounter.ValueHistoryLen];
						cache.GraphColors = new ColorRgba[ProfileCounter.ValueHistoryLen];
						this.graphCache[counterName] = cache;
					}
					cache.WasUsed = true;

					float cursorRatio = 0.0f;
					if (counter is TimeCounter)
					{
						TimeCounter timeCounter = counter as TimeCounter;
						for (int i = 0; i < ProfileCounter.ValueHistoryLen; i++)
						{
							float factor = timeCounter.ValueGraph[i] / Time.MsPFMult;
							cache.GraphValues[i] = factor * 0.75f;
							cache.GraphColors[i] = ColorRgba.Lerp(ColorRgba.White, ColorRgba.Red, factor);
						}
						canvas.CurrentState.ColorTint = ColorRgba.Black.WithAlpha(0.5f);
						canvas.FillRect(graphRect.X, graphY, graphRect.W, graphH);
						canvas.CurrentState.ColorTint = ColorRgba.White;
						canvas.DrawHorizontalGraph(cache.GraphValues, cache.GraphColors, ref cache.VertGraph, graphRect.X, graphY, graphRect.W, graphH);
						cursorRatio = (float)timeCounter.ValueGraphCursor / (float)ProfileCounter.ValueHistoryLen;
					}
					else if (counter is StatCounter)
					{
						StatCounter statCounter = counter as StatCounter;
						for (int i = 0; i < ProfileCounter.ValueHistoryLen; i++)
						{
							cache.GraphValues[i] = (float)(statCounter.ValueGraph[i] - statCounter.MinValue) / statCounter.MaxValue;
//.........这里部分代码省略.........
开发者ID:KETMGaming,项目名称:duality,代码行数:101,代码来源:ProfileRenderer.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IDrawable类代码示例发布时间:2022-05-24
下一篇:
C# IDownloadService类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap