| View previous topic :: View next topic |
| Author |
Message |
RCON
Joined: 03 Aug 2005 Posts: 16
|
Posted: Thu Sep 15, 2005 2:50 pm Post subject: psprtc.h |
|
|
Has anyone figured out how to use the psprtc.h include? I am trying to overcome some timing issues I am having with the clock() function in time.h. The sceRtcGetCurrentTick(u64 *tick) function looks promising but I don't know exactly how to use it.
-Louie |
|
| Back to top |
|
 |
RustyFunkNut
Joined: 26 Sep 2005 Posts: 17 Location: London, UK
|
Posted: Mon Sep 26, 2005 5:21 am Post subject: |
|
|
Here's what I'm using (assumes C++, but easy to convert to C):
| Code: |
static u64 gLastTick = 0;
static float gFreqInv;
void RenderFrame()
{
u64 current_tick;
float elapsed_time( 0.0f );
if(sceRtcGetCurrentTick( ¤t_tick ) == 0)
{
if(gLastTick == 0)
{
u32 ticks_per_second( sceRtcGetTickResolution() );
gFreqInv = 1.0f / float( ticks_per_second );
gLastTick = current_tick;
}
u64 elapsed_ticks( current_tick - gLastTick );
elapsed_time = float(elapsed_ticks) * gFreqInv;
gLastTick = current_tick;
}
// Elapsed time in seconds is in elapsed_time (or 0.0f if the call failed)
}
|
It should be fairly clear what's going on. The main thing is that sceRtcGetCurrentTick() returns 0 on success.
I'm not sure what the resolution of the timer is, but it should be accurate to at least 1 millisecond.
Hope that helps! |
|
| Back to top |
|
 |
RCON
Joined: 03 Aug 2005 Posts: 16
|
Posted: Mon Sep 26, 2005 5:29 am Post subject: |
|
|
| thanks, that does help |
|
| Back to top |
|
 |
|