SDL School

API reference / Application

SDL_AppIterate

Function, SDL3

You write this function, and SDL calls it again and again, about one time for each frame. Update and draw here.

Declaration

#include <SDL3/SDL.h>

SDL_AppResult SDL_AppIterate(void *appstate);

Parameters

appstateThe pointer that you stored in SDL_AppInit.

Return value

SDL_APP_CONTINUE to keep running, or SDL_APP_SUCCESS or SDL_APP_FAILURE to end the program.

Example

Open a window
SDL_AppResult SDL_AppIterate(void *appstate)
{
    SDL_SetRenderDrawColor(renderer, 32, 96, 160, SDL_ALPHA_OPAQUE);
    SDL_RenderClear(renderer);
    SDL_RenderPresent(renderer);
    return SDL_APP_CONTINUE;
}

See this code run in Open a window. Download the full program (.zip)

Notes

In SDL2

SDL2 has no main callbacks. You write your own frame function and a loop.

See also