'' SDL2-Example program:
'' Using SDL2 to create an application windw
'' translated by TJF 2013

#INCLUDE ONCE "SDL2/SDL2.bi"

'/* Initialize SDL */
IF SDL_Init(SDL_INIT_VIDEO) < 0 THEN
  SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, _
    !"Couldn't initialize SDL: %s\n", SDL_GetError())
  END 2
END IF

VAR posX = 100, posY = 100, wdth = 408, hght = 167

VAR win = SDL_CreateWindow("Hello World", posX, posY, wdth, hght, 0)

VAR bitmapSurface = SDL_LoadBMP("sdl.bmp")
VAR renderer = SDL_CreateSoftwareRenderer(bitmapSurface)
VAR bitmapTex = SDL_CreateTextureFromSurface(renderer, bitmapSurface)
SDL_FreeSurface(bitmapSurface)

DIM AS SDL_Event event
DO
  IF (SDL_PollEvent(@event) <> 0) ANDALSO (event.type = SDL_QUIT_) THEN EXIT DO

  SDL_RenderClear(renderer)
  SDL_RenderCopy(renderer, bitmapTex, NULL, NULL)
  SDL_RenderPresent(renderer)
LOOP

SDL_DestroyTexture(bitmapTex)
SDL_DestroyRenderer(renderer)
SDL_DestroyWindow(win)
SDL_Quit()
