Intro #
How Chapter 5 works? #
- init()
SDL_Init()SDL_CreateWindow()SDL_GetWindowSurface()
- loadMedia()
- loadSurface()
- load BMP file on intermediate surface with
SDL_LoadBMP(). - optimize loaded intermediate surface into optimized surface with
SDL_ConvertSurface().- free memory of intermediate surface with
SDL_FreeSurface().
- free memory of intermediate surface with
- load BMP file on intermediate surface with
- loadSurface()
- start loop untill variable
quitis true.- start loop that calls
SDL_PollEvent()untill it returns 0.- if
SDL_Event.typeisSDL_QUIT, quit is true( which means first loop will end). - copy screen(Blit) scaled one with
SDL_BlitScaled(). - 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_ConvertSurface() #
SDL_Surface* SDL_ConvertSurface( SDL_Surface* src, const SDL_PixelFormat* fmt, Uint32 flags );
- param
src: the existing SDL_Surface structure to convertfmt: the SDL_PixelFormat structure that the new surface is optimized forflags: the flags are unused and should be set to 0; this is a leftover from SDL 1.2’s API
- return
- new surface on success
- NULL on failure
get surface
srcand convert it into specific format thatfmtindicating.
SDL_BlitScaled() #
int SDL_BlitScaled( SDL_Surface* src, const SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect );
- param
src: the SDL_Surface structure to be copied fromsrcrect: the SDL_Rect structure representing the rectangle to be copied, or NULL to copy entire surfacedst: the SDL_Surface structure that is the blit targetdstrect: the SDL_Rect structure representing the rectangle that is copied into, or NULL to copy into the entire surface
- return
- 0 on success
- negative integer as error code on failure
Simiral with
SDL_BlitSurface()but blit scaled surface.
this function callSDL_LowerBlitScaled()internally.
Struct #
SDL_PixelFormat #
Term #
- nothing new