Intro #
How Chapter 3 works? #
- Init()
SDL_Init()
SDL_CreateWindow()
SDL_GetWindowSurface()
- loadMedia()
SDL_LoadBMP()
- start loop untill variable
quit
is true.- start loop that calls
SDL_PollEvent()
untill it returns 0.- if
SDL_Event
.type isSDL_QUIT
, quit is true( which means first loop will end). - copy screen(Blit) with
SDL_BlitSurface()
. - update window with
SDL_UpdateWindowSurface()
to refresh and show what we’ve done.
- if
- start loop that calls
- close()
SDL_FreeSurface()
SDL_DestroyWindow()
SDL_Quit()
Function #
SDL_PollEvent() #
int SDL_PollEvent( SDL_Event* event );
- param
event
: the SDL_Event structure to be filled with the next event from the queue, or NULL
- return
- 1 if queue contains any event inside
- 0 if there’s no event in queue
when this function called, event at head will be removed from queue and stored to
event
.
(return value 1 shows this works happend) (NULL inside queue won’t works like this)
this function implicitly contains SDL_PumpEvent().
Struct #
SDL_Event #
general cross-platform event struct
contains event data
Term #
SDL_Event..type #
- SDL_QUIT