SDL School

API reference / Input and time

SDL_GetTicksNS

Function, SDL3

Gets the time since SDL started, in nanoseconds. Use two readings to measure a time.

Declaration

#include <SDL3/SDL.h>

Uint64 SDL_GetTicksNS(void);

Return value

The number of nanoseconds.

Example

Move with time
last_ticks = SDL_GetTicksNS();

See this code run in Move with time. Download the full program (.zip)

Notes

In SDL2

SDL2 has no such function. Use SDL_GetPerformanceCounter with SDL_GetPerformanceFrequency.

See also