SDL3_gfx 1.0.1 Graphics primitives and surface functions for SDL3

Data Structures | Macros | Functions
SDL3_framerate.h File Reference
`#include <SDL3/SDL.h>`

Go to the source code of this file.

## Data Structures
struct | FPSmanager
| Structure holding the state and timing information of the framerate controller. More...

## Macros
#define | FPS_UPPER_LIMIT 200
| Highest possible rate supported by framerate controller in Hz (1/s).
#define | FPS_LOWER_LIMIT 1
| Lowest possible rate supported by framerate controller in Hz (1/s).
#define | FPS_DEFAULT 30
| Default rate of framerate controller in Hz (1/s).
#define | SDL3_FRAMERATE_SCOPE extern

## Functions
SDL3_FRAMERATE_SCOPE void | SDL_initFramerate (FPSmanager *manager)
| Initialize the framerate manager.
SDL3_FRAMERATE_SCOPE int | SDL_setFramerate (FPSmanager *manager, Uint32 rate)
| Set the framerate in Hz.
SDL3_FRAMERATE_SCOPE int | SDL_getFramerate (FPSmanager *manager)
| Return the current target framerate in Hz.
SDL3_FRAMERATE_SCOPE int | SDL_getFramecount (FPSmanager *manager)
| Return the current framecount.
SDL3_FRAMERATE_SCOPE Uint64 | SDL_framerateDelay (FPSmanager *manager)
| Delay execution to maintain a constant framerate and calculate fps.

## Macro Definition Documentation

## ◆ FPS_DEFAULT

#define FPS_DEFAULT 30

Default rate of framerate controller in Hz (1/s).

Definition at line 57 of file SDL3_framerate.h.

## ◆ FPS_LOWER_LIMIT

#define FPS_LOWER_LIMIT 1

Lowest possible rate supported by framerate controller in Hz (1/s).

Definition at line 52 of file SDL3_framerate.h.

## ◆ FPS_UPPER_LIMIT

#define FPS_UPPER_LIMIT 200

Highest possible rate supported by framerate controller in Hz (1/s).

Definition at line 47 of file SDL3_framerate.h.

## ◆ SDL3_FRAMERATE_SCOPE

#define SDL3_FRAMERATE_SCOPE extern

Definition at line 82 of file SDL3_framerate.h.

## Function Documentation

## ◆ SDL_framerateDelay()

SDL3_FRAMERATE_SCOPE Uint64 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

  manager | Pointer 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 SDL3_framerate.c.

## ◆ SDL_getFramecount()

SDL3_FRAMERATE_SCOPE 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

  manager | Pointer to the framerate manager.

Returns
  Current frame count or -1 for error.

Definition at line 126 of file SDL3_framerate.c.

## ◆ SDL_getFramerate()

SDL3_FRAMERATE_SCOPE int SDL_getFramerate | ( | FPSmanager * | manager | ) |

Return the current target framerate in Hz.

Get the currently set framerate of the manager.

Parameters

  manager | Pointer to the framerate manager.

Returns
  Current framerate in Hz or -1 for error.

Definition at line 107 of file SDL3_framerate.c.

## ◆ SDL_initFramerate()

SDL3_FRAMERATE_SCOPE void SDL_initFramerate | ( | FPSmanager * | manager | ) |

Initialize the framerate manager.

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

Parameters

  manager | Pointer to the framerate manager.

Definition at line 62 of file SDL3_framerate.c.

## ◆ SDL_setFramerate()

SDL3_FRAMERATE_SCOPE 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

  manager | Pointer to the framerate manager.
  rate | The new framerate in Hz (frames per second).

Returns
  0 for sucess and -1 for error.

Definition at line 86 of file SDL3_framerate.c.