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
appstate | The 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
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
- Return quickly. A browser cannot show a new frame until this function returns.
- Do not call
SDL_PollEventhere, because SDL sends events toSDL_AppEvent.
In SDL2
SDL2 has no main callbacks. You write your own frame function and a loop.