SDL2_gfx  1.0.2
Graphics primitives and surface functions for SDL2
Functions
/build/libsdl2-gfx-F3NxcE/libsdl2-gfx-1.0.4+dfsg/SDL2_framerate.c File Reference
#include "SDL2_framerate.h"

Go to the source code of this file.

Functions

Uint32 _getTicks ()
 Internal wrapper to SDL_GetTicks that ensures a non-zero return value. More...
 
void SDL_initFramerate (FPSmanager *manager)
 Initialize the framerate manager. More...
 
int SDL_setFramerate (FPSmanager *manager, Uint32 rate)
 Set the framerate in Hz. More...
 
int SDL_getFramerate (FPSmanager *manager)
 Return the current target framerate in Hz. More...
 
int SDL_getFramecount (FPSmanager *manager)
 Return the current framecount. More...
 
Uint32 SDL_framerateDelay (FPSmanager *manager)
 Delay execution to maintain a constant framerate and calculate fps. More...
 

Function Documentation

◆ _getTicks()

Uint32 _getTicks ( )

Internal wrapper to SDL_GetTicks that ensures a non-zero return value.

Returns
The tick count.

Definition at line 37 of file SDL2_framerate.c.

◆ SDL_framerateDelay()

Uint32 SDL_framerateDelay ( FPSmanager manager)

Delay execution to maintain a constant framerate and calculate fps.

Generate a delay to accomodate currently set framerate. Call once in the graphics/rendering loop. If the computer cannot keep up with the rate (i.e. drawing too slow), the delay is zero and the delay interpolation is reset.

Parameters
managerPointer to the framerate manager.
Returns
The time that passed since the last call to the function in ms. May return 0.

Definition at line 146 of file SDL2_framerate.c.

◆ SDL_getFramecount()

int SDL_getFramecount ( FPSmanager manager)

Return the current framecount.

Get the current framecount from the framerate manager. A frame is counted each time SDL_framerateDelay is called.

Parameters
managerPointer to the framerate manager.
Returns
Current frame count or -1 for error.

Definition at line 126 of file SDL2_framerate.c.

◆ SDL_getFramerate()

int SDL_getFramerate ( FPSmanager manager)

Return the current target framerate in Hz.

Get the currently set framerate of the manager.

Parameters
managerPointer to the framerate manager.
Returns
Current framerate in Hz or -1 for error.

Definition at line 107 of file SDL2_framerate.c.

◆ SDL_initFramerate()

void SDL_initFramerate ( FPSmanager manager)

Initialize the framerate manager.

Initialize the framerate manager, set default framerate of 30Hz and reset delay interpolation.

Parameters
managerPointer to the framerate manager.

Definition at line 62 of file SDL2_framerate.c.

◆ SDL_setFramerate()

int SDL_setFramerate ( FPSmanager manager,
Uint32  rate 
)

Set the framerate in Hz.

Sets a new framerate for the manager and reset delay interpolation. Rate values must be between FPS_LOWER_LIMIT and FPS_UPPER_LIMIT inclusive to be accepted.

Parameters
managerPointer to the framerate manager.
rateThe new framerate in Hz (frames per second).
Returns
0 for sucess and -1 for error.

Definition at line 86 of file SDL2_framerate.c.