本文整理汇总了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
}