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
psprtc.h
-
- Posts: 17
- Joined: Mon Sep 26, 2005 5:10 am
- Location: London, UK
Here's what I'm using (assumes C++, but easy to convert to C):
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!
Code: Select all
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)
}
I'm not sure what the resolution of the timer is, but it should be accurate to at least 1 millisecond.
Hope that helps!