#include "DxLib.h"
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
int time;
short int fps_count = 0;//60フレームカウント
LONGLONG fps_t = 0;//時間取得
int fps_num = 0;//fpsの数値
SetAlwaysRunFlag( TRUE );//非アクティブ時の処理
ChangeWindowMode(TRUE);
// DXライブラリの初期化
if( DxLib_Init() < 0 )
{
// エラーが発生したら直ちに終了
return -1 ;
}
SetDrawScreen( DX_SCREEN_BACK );
while( ScreenFlip()==0 && ProcessMessage()==0 && ClearDrawScreen()==0 ){
time = GetNowCount();
if(fps_count % 60 == 0){//fps計算
if(fps_count)
fps_num = int(GetNowHiPerformanceCount() - fps_t) / 60;
fps_t = GetNowHiPerformanceCount();
fps_count = 0;
}
fps_count++;
if(fps_num)//fps描画
DrawFormatString( 0 , 0 , GetColor(255,255,255) , "%.2ffps" , 1000000.00/(double)fps_num );
WaitTimer( 16 - (GetNowCount() - time) );
}
// DXライブラリの後始末
DxLib_End() ;
// ソフトの終了
return 0 ;
}
このソースで50〜60フレームくらいになり安定しません。
なぜか SetAlwaysRunFlag( TRUE ); か WaitTimer( 16 - (GetNowCount() - time) ); のどちらかをコメントアウトすると60フレームで安定するのですが
出来ることなら両方有効にしておきたいです。
これはライブラリのバグなのでしょうか、それともソースが悪いのでしょうか。
環境はwin7 64bit VC2010です。