Hello guys.
I know this is quite trivial but apparently not to me
I created a time object and with StartWatch() at the beginning of the program I measure time. Then I'd like to see the time running on screen. How to do this?
ANy help welcome
how to show the time on screen? [solved]
how to show the time on screen? [solved]
Last edited by Clodi on January 26th, 2013, 7:56 pm, edited 1 time in total.
Re: how to show the time on screen?
this is my code, it runs fine but nothing appears on screen. ??
Code: Select all
if ( FrameCounter == 0 )
{
FrameCounter = 1;
timer.StartWatch();
}
else if ( FrameCounter == 10 )
{
FrameCounter = 0;
timer.StopWatch();
x = 10000 / timer.GetTimeMilli();
}
else
{
FrameCounter ++;
}
char Buffer[ 64 ];
sprintf( Buffer,"%d frames per sec.",x );
gfx.DrawString( Buffer,100,100,&fixedSys,D3DCOLOR_XRGB( 255,0,0 ) );
Re: how to show the time on screen?
I think I may have a soultion although I am having trouble in my game with time.
I would call stop watch first and gettimrmuli second then finally stop watch.
I would call stop watch first and gettimrmuli second then finally stop watch.
Computer too slow? Consider running a VM on your toaster.
Re: how to show the time on screen?
nope
The problem is with the DrawString function. Nothing shows up anyway.
Even if I commented everything out and I tried to print x (x = 0) , it would not print.
The problem is with the DrawString function. Nothing shows up anyway.
Even if I commented everything out and I tried to print x (x = 0) , it would not print.
Re: how to show the time on screen?
it now works
Code: Select all
//frame per sec.
if ( FrameCounter == 0 ) { FrameCounter = 1; timer.StartWatch(); }
else if ( FrameCounter == 10 ) { FrameCounter = 0; timer.StopWatch(); x = 10000 / timer.GetTimeMilli(); }
else { FrameCounter ++; }
char Buffer[ 64 ];
sprintf( Buffer,"%f frames per sec.",x );
gfx.DrawString( Buffer,0,0,&fixedSys,D3DCOLOR_XRGB( 255,0,0 ) );
//sec. from start
y = timer2.GetTimeMilli()/1000;
char Buffer2[ 64 ];
sprintf( Buffer2,"%f sec. u waste",y );
gfx.DrawString( Buffer2,0,20,&fixedSys,D3DCOLOR_XRGB( 255,0,0 ) );
Re: how to show the time on screen?
You should also use "sprintf_s" instead. You probably have your compiler complaining about warnings, something like "sprintf depreciated, use sprintf_s instead".
ʕ •ᴥ•ʔ