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


C# DrawState.GetCurrentFrameStatistics方法代码示例

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


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

示例1: Draw


//.........这里部分代码省略.........
			stats -= previousFrameOverhead;

			if (graphs == null)
			{
				const int width = 210;
				const int height = 128;
				const int fontPix = 20;
				List<Call> calls = new List<Call>();

				Func<string, Call, float, Graph> add = delegate(string name, Call call, float good) { calls.Add(call); return new Graph(name, width, height, width - fontPix / 2, fontPix, 0, font, -good); };
				Func<string, Call, float, Graph> addHalf = delegate(string name, Call call, float good) { calls.Add(call); return new Graph(name, width / 2, height, width / 2 - fontPix / 2, fontPix, 0, font, -good); };
				Func<string, Call, float, Graph> addHalfMin1 = delegate(string name, Call call, float good) { calls.Add(call); return new Graph(name, width / 2, height, width / 2 - fontPix / 2, fontPix, 1, font, -good); };

				graphs = new Graph[]
				{
					add("Frame Rate (Approx)",delegate(ref DrawStatistics s, DrawState dstate)
						{return (float)dstate.ApproximateFrameRate;}, -20),
					
#if XBOX360
					addHalf("Primitives Drawn",delegate(ref DrawStatistics s, DrawState dstate)
					    {return (float)(s.TrianglesDrawn+s.LinesDrawn+s.PointsDrawn);}, 1000000),

					addHalf("Pixels Drawn\n(Approx)",delegate(ref DrawStatistics s, DrawState dstate)
					    {return Math.Max(0,pixelsFillled - (float)s.XboxPixelFillBias);}, 20000000), // not accurate
#else
			
					add("Primitives Drawn",delegate(ref DrawStatistics s, DrawState dstate)
					    {return (float)(s.TrianglesDrawn+s.LinesDrawn+s.PointsDrawn);}, 1000000),

					addHalf("Pixels Drawn",delegate(ref DrawStatistics s, DrawState dstate)
					    {return Math.Max(0,pixelsFillled);}, 18000000),
#endif
					
					addHalf("Draw Calls",delegate(ref DrawStatistics s, DrawState dstate)
					    {return (float)(s.DrawIndexedPrimitiveCallCount + s.DrawPrimitivesCallCount);}, 300),
					
					addHalf("Garbage Collected",delegate(ref DrawStatistics s, DrawState dstate)
					    {
							if (garbageTracker.Target == null) { garbageTracker.Target = new object(); return 1; }
							return 0;
						},0),
						
					addHalf("Allocated Bytes (Managed)",delegate(ref DrawStatistics s, DrawState dstate)
					    {
							return (int)GC.GetTotalMemory(false);
						},0),
					
#if XBOX360
					
					addHalfMin1("CPU Usage\n(Primary)",delegate(ref DrawStatistics s, DrawState dstate)
					    {return threads[0].Usage;},-0.5f),
					addHalfMin1("CPU Usage\n(Task Threads)",delegate(ref DrawStatistics s, DrawState dstate)
					    {return (threads[1].Usage+threads[2].Usage+threads[3].Usage) / 3.0f;},-0.25f),
#endif
						
				};

				this.setGraphCalls = calls.ToArray();
			}

			for (int i = 0; i < graphs.Length; i++)
			{
				graphs[i].SetGraphValue(setGraphCalls[i](ref stats, state));
				graphs[i].Visible = true;
			}

			AlignElements(state);


			DrawStatistics currentPreDraw;
			state.GetCurrentFrameStatistics(out currentPreDraw);


			for (int i = 0; i < graphs.Length; i++)
			{
				if (graphs[i].Visible)
					graphs[i].Draw(state);
			}


			DrawStatistics currentPostDraw;
			state.GetCurrentFrameStatistics(out currentPostDraw);

			previousFrameOverhead = currentPostDraw - currentPreDraw;


			if (state.Application.IsHiDefDevice)
			{
				if (fillRateQuery.IsComplete)
				{
					pixelsFillled = (float)fillRateQuery.PixelCount;

					fillRateQuery.Begin();
					fillRateQueryActive = true;
				}
			}
			else
				pixelsFillled = -1;
#endif
		}
开发者ID:shadarath,项目名称:Wirtualna-rzeczywistosc,代码行数:101,代码来源:Stats.cs


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