This document is not done. On Going!!


Intro

How Chapter 7 works?

  1. init()
    1. SDL_Init()
    2. SDL_SetHint()
    3. SDL_CreateWindow()
    4. SDL_CreateRenderer()
    5. SDL_SetRenderDrawColor()
    6. IMG_Init()
  2. loadMedia()
    1. loadTexture()
      1. load PNG file on intermediate surface with IMG_Load().
      2. create texture from loaded surface with SDL_CreateTextureFromSurface().
        • free memory of intermediate surface with SDL_FreeSurface().
  3. start loop untill variable quit is true.
    1. start loop that calls SDL_PollEvent() untill it returns 0.
      1. if SDL_Event.type is SDL_QUIT, quit is true( which means first loop will end).
      2. clear screen(render) with SDL_RenderClear().
      3. render texture(copy) on screen with SDL_RenderCopy().
      4. update screen(of window) with SDL_RenderPresent() to refresh and show what we’ve done.
  4. close()
    1. SDL_DestroyTexture()
    2. SDL_DestroyRenderer()
    3. SDL_DestroyWindow()
    4. IMG_Quit()
    5. SDL_Quit()
  • now we are not using screen surface as our primary canvas anymore; instead renderer!
    • loadSueface() -> loadTexture()
    • SDL_GetWindowSurface() is gone from init()
      • instead, SDL_SetHint(), SDL_CreateRenderer() and SDL_SetRenderDrawColor() are required
    • SDL_BlitSurface() is replaced into SDL_RenderClear() and SDL_RenderCopy()
    • SDL_UpdateWindowSurface() is replaced into SDL_RenderPresent()
    • SDL_FreeSurface() is gone from close()
      • instead, SDL_DestroyTexture() and SDL_DestroyRenderer() are required

Function

SDL_SetHint()

1

  • param
    • `` :
  • return
    • **** on

SDL_CreateRenderer()

1

  • param
    • `` :
  • return
    • **** on

SDL_SetRenderDrawColor()

1

  • param
    • `` :
  • return
    • **** on

SDL_CreateTextureFromSurface()

1

  • param
    • `` :
  • return
    • **** on

SDL_RenderClear()

1

  • param
    • `` :
  • return
    • **** on

SDL_RenderCopy()

1

  • param
    • `` :
  • return
    • **** on

SDL_RenderPresent()

1

  • param
    • `` :
  • return
    • **** on

SDL_DestroyTexture()

1

  • param
    • `` :
  • return
    • **** on

SDL_DestroyRender()

1

  • param
    • `` :
  • return
    • **** on

Struct

SDL_Renderer

SDL_Texture


Term

SDL_SetHint()

  • SDL_HINT_RENDER_SCALE_QUALITY

SDL_CreateRender()

  • SDL_RENDERER_ACCELERATED