GSDP:GAM100/CProcessing/CP System SetFrameRate()

From Inside
Jump to: navigation, search

CP_System_SetFrameRate()

Description

Sets the target frame rate (fps) for the application.

The internal frame rate controller manages when each update call happens. If the processing required to complete one update finishes quickly then the frame rate controller will idle the CPU. Once the total desired frame time has passed it will then start the next frame. If the processing required to complete one update takes longer than one frame's worth of time then the next frame will start immediately.

Parameters

CP_System_SetFrameRate(float fps)

  • fps - the target application update speed in frames per second.

Example

void init(void)
{
    // set framerate to 2 fps (slow)
    CP_System_SetFrameRate(2.0f);

    // initialize settings
    CP_Settings_TextSize(200);
    CP_Settings_TextAlignment(CP_TEXT_ALIGN_H_CENTER, CP_TEXT_ALIGN_V_MIDDLE);
    CP_Settings_Fill(CP_Color_Create(100, 20, 100, 255));
}

void update(void) 
{
    // clear the screen
    CP_Settings_Background(CP_Color_Create(200, 200, 200, 255));

    // print the current frame count to the center of the window
    int currentFrameCount = CP_System_GetFrameCount();
    
    char buffer[16] = { 0 };
    sprintf_s(buffer, _countof(buffer), "%i", currentFrameCount);
    CP_Font_DrawText(buffer, 200, 200);
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>