Original Post
🔒 Locked
PR_GetTicks()
Advertisement
Hi Nat
According to the info from the pr.chm the HTML help file:
Function:
Returns the time passed
Declaration: PR_DWORD PR_GetTicks (void)
Remarks: This routine will return the number of ticks passed since the last time you called it. This can be used as a multiplier in all your object movements so they move the same speed regardless of the CPU or 3D card you use.
Parameters: None
Return Value: Ticks passed since last call
See Also: PR_InitTimer
Usually in your code the PR_GetTicks function is used like
this:
move_count = PR_GetTicks();
You then take this move_count and mulitply it by
all the movement varibles such as rotation and translation
to get a consistent frame rate.
I used this function to get consistent frame rates by using
this function. Usually without using this function you will
get higher than nomal frame rates but without the consistent frame rates. As an example a simple cube would give a high FPS count while an object such as a high face count like a sphere would give you a lower frame rate. Using the PR_GetTick function you will get a more consistent frame rates when moving about your scene. There will be some variances from the target frame rate thats set using the PR_InitTimer function, but you will not get those wide frame rate swings without using the PR_GetTicks function.
As for a frame rate counter you could use something like this:
This is the include file:
time.h
These are the varibles I used:
clock_t time = 0, timelast = 0;
PR_DWORD frame = 0, count = 0;
// Used to display Frame Rate
time = clock(); // Standard C timer function
count++;
if(time - timelast >= 1000)
{
frame = count;
timelast = time;
count = 0;
}
PRGUI_printf(15,160,"FPS: %d", frame);
There is however two functions that uses the PR_GetTicks function that is from the land1.c file that displays FPS:
void ResetFPS (void)
{
updates = 0;
ticks = 0;
brightcolor = PRGFX_MakeColor (63, 63, 63);
darkcolor = PRGFX_MakeColor (0, 0, 0);
}
void ShowFPS (PR_DWORD move_count)
{
ticks += move_count;
/* Calculate the frame rate */
if (ticks > 60)
{
framerate = updates;
ticks = 0;
updates = 0;
}
else
updates++;
PR_OpenScreen (PR_BACKBUFFER);
PRGFX_Clip (0,0, vwidth-1, vheight-1);
PRGFX_SetTextForeground (brightcolor);
PRGFX_SetTextBackground (darkcolor);
PRGFX_SetTextTransparent (TEXTFGBG);
PRGUI_printf (vwidth - 30, 2, "%i", framerate);
}
Hope this helps
Doug
Edited by - sovereign on 4/14/00 3:28:11 PM
Edited by - Sovereign on 4/14/00 3:31:38 PM
Edited by - Sovereign on 4/14/00 3:35:17 PM
According to the info from the pr.chm the HTML help file:
Function:
Returns the time passed
Declaration: PR_DWORD PR_GetTicks (void)
Remarks: This routine will return the number of ticks passed since the last time you called it. This can be used as a multiplier in all your object movements so they move the same speed regardless of the CPU or 3D card you use.
Parameters: None
Return Value: Ticks passed since last call
See Also: PR_InitTimer
Usually in your code the PR_GetTicks function is used like
this:
move_count = PR_GetTicks();
You then take this move_count and mulitply it by
all the movement varibles such as rotation and translation
to get a consistent frame rate.
I used this function to get consistent frame rates by using
this function. Usually without using this function you will
get higher than nomal frame rates but without the consistent frame rates. As an example a simple cube would give a high FPS count while an object such as a high face count like a sphere would give you a lower frame rate. Using the PR_GetTick function you will get a more consistent frame rates when moving about your scene. There will be some variances from the target frame rate thats set using the PR_InitTimer function, but you will not get those wide frame rate swings without using the PR_GetTicks function.
As for a frame rate counter you could use something like this:
This is the include file:
time.h
These are the varibles I used:
clock_t time = 0, timelast = 0;
PR_DWORD frame = 0, count = 0;
// Used to display Frame Rate
time = clock(); // Standard C timer function
count++;
if(time - timelast >= 1000)
{
frame = count;
timelast = time;
count = 0;
}
PRGUI_printf(15,160,"FPS: %d", frame);
There is however two functions that uses the PR_GetTicks function that is from the land1.c file that displays FPS:
void ResetFPS (void)
{
updates = 0;
ticks = 0;
brightcolor = PRGFX_MakeColor (63, 63, 63);
darkcolor = PRGFX_MakeColor (0, 0, 0);
}
void ShowFPS (PR_DWORD move_count)
{
ticks += move_count;
/* Calculate the frame rate */
if (ticks > 60)
{
framerate = updates;
ticks = 0;
updates = 0;
}
else
updates++;
PR_OpenScreen (PR_BACKBUFFER);
PRGFX_Clip (0,0, vwidth-1, vheight-1);
PRGFX_SetTextForeground (brightcolor);
PRGFX_SetTextBackground (darkcolor);
PRGFX_SetTextTransparent (TEXTFGBG);
PRGUI_printf (vwidth - 30, 2, "%i", framerate);
}
Hope this helps
Doug
Edited by - sovereign on 4/14/00 3:28:11 PM
Edited by - Sovereign on 4/14/00 3:31:38 PM
Edited by - Sovereign on 4/14/00 3:35:17 PM
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement