|
|
引擎部分:
DiamondText: iamondText( int height )
{
D3DXCreateFont( DiamondEngineDevice, height, 0, FW_NORMAL,
1, false, GB2312_CHARSET, OUT_DEFAULT_PRECIS,
ANTIALIASED_QUALITY, DEFAULT_PITCH|FF_DONTCARE, L"微软雅黑", &font );
}
DiamondText::~DiamondText( void )
{
font->Release();
}
void DiamondText::Draw( wchar_t* string, int x, int y, unsigned int color )
{
RECT rect = { x, y, 0, 0 };
font->DrawText( NULL, string, -1, &rect, DT_LEFT|DT_NOCLIP, color );
}
DEMO部分:
DiamondEngine* diamondEngine = new DiamondEngine( L"DiamondEngine", NULL, 800, 600, false );
DiamondText* diamondText = new DiamondText( 20 );
while ( diamondEngine->Running() )
{
diamondEngine->BeginRender();
for ( int x=0; x<700; x+=200 )
{
for ( int y=0; y<600; y+=20 )
{
wchar_t text[32];
swprintf_s( text, 16, L"FPS : %d 帧", diamondEngine->GetFramePerSecond() );
diamondText->Draw( text, x, y, 0xFF00FF00 );
swprintf_s( text, 16, L"时间 : %.4lf 秒", diamondEngine->GetRealTime() );
diamondText->Draw( text, x+80, y, 0xFF00FF00 );
}
}
diamondEngine->EndRender();
}
如果不输出这些文字,FPS:10000左右!
输出这些文字20个左右,FPS降到1000左右!
用上面的代码输出满屏的文字,FPS:28!
为什么这么慢?仅仅是输出一些文字啊!
哪位给指点一下迷津```谢谢 |
|