?? ddfpspainter.cs
字號:
using System;
using System.Drawing;
using Microsoft.DirectX.DirectDraw;
namespace DDGameHelper
{
public class DDFPSPainter
{
/// <summary>
/// 顯示字符信息用的 surface
/// </summary>
protected Surface _textSurface;
/// <summary>
/// 輸出用 surface
/// </summary>
protected Surface _renderSurface;
/// <summary>
/// 初始化 surface
/// </summary>
public DDFPSPainter(Device dddevice, Surface renderSurface)
{
_renderSurface=renderSurface;
SurfaceDescription description=new SurfaceDescription();
description.SurfaceCaps.OffScreenPlain = true;
description.Width = 400; description.Height = 20;
ColorKey tempKey = new ColorKey();
tempKey.ColorSpaceHighValue = 0;
tempKey.ColorSpaceLowValue = 0;
_textSurface = new Surface(description, dddevice);
_textSurface.ForeColor = Color.White;
_textSurface.SetColorKey(ColorKeyFlags.SourceDraw, tempKey);
}
/// <summary>
/// 顯示 fps 及附加字符串到屏幕上
/// </summary>
public void PaintFPS(DXTimer dXTimer, string append)
{
double fps=dXTimer.CalculateFPS();
string s="FPS:"+((int)fps).ToString()+append;
_textSurface.ColorFill(0);
_textSurface.DrawText(0, 0, s , false);
_renderSurface.DrawFast(10, 10, _textSurface, DrawFastFlags.SourceColorKey | DrawFastFlags.DoNotWait);
}
/// <summary>
/// 顯示 fps 數據到屏幕上
/// </summary>
public void PaintFPS(DXTimer dXTimer)
{
double fps=dXTimer.CalculateFPS();
string s="FPS:"+((int)fps).ToString();
_textSurface.ColorFill(0);
_textSurface.DrawText(0, 0, s , false);
_renderSurface.DrawFast(10, 10, _textSurface, DrawFastFlags.SourceColorKey | DrawFastFlags.DoNotWait);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -