<commit_before># Test the SDL interface:

import
  SDL

var
  screen, greeting: PSurface
  r: TRect

if Init(INIT_VIDEO) == 0:
  screen = SetVideoMode(640, 480, 16, SWSURFACE or ANYFORMAT)
  if screen == nil:
    write(stdout, "screen is nil!\n")
  else:
    greeting = LoadBmp("backgrnd.bmp")
    if greeting == nil:
      write(stdout, "greeting is nil!")
    r.x = 0'i16
    r.y = 0'i16
    discard blitSurface(greeting, nil, screen, addr(r))
    discard flip(screen)
    Delay(3000)
else:
  write(stdout, "SDL_Init failed!\n")

sdl.Quit()<commit_msg>Update examples/sdlex.nim<commit_after># Test the SDL interface:

import
  sdl, sdl_image, colors

var
  screen, greeting: PSurface
  r: TRect
  event: TEvent
  bgColor = colChocolate.int32

if init(INIT_VIDEO) != 0:
  quit "SDL failed to initialize!"

screen = SetVideoMode(640, 480, 16, SWSURFACE or ANYFORMAT)
if screen.isNil:
  quit($sdl.getError())

greeting = IMG_load("tux.png")
if greeting.isNil:
  echo "Failed to load tux.png"
else:
  ## convert the image to alpha and free the old one
  var s = greeting.displayFormatAlpha()
  swap(greeting, s)
  s.freeSurface()

r.x = 0
r.y = 0

block game_loop:
  while true:
    
    while pollEvent(addr event) > 0:
      case event.kind
      of QUITEV:
        break game_loop
      of KEYDOWN:
        if EvKeyboard(addr event).keysym.sym == K_ESCAPE:
          break game_loop
      else:
        discard
    
    discard fillRect(screen, nil, bgColor) 
    discard blitSurface(greeting, nil, screen, addr r)
    discard flip(screen)

greeting.freeSurface()
screen.freeSurface()
sdl.Quit()

## fowl wuz here 10/2012
{'fraction_non_alphanumeric': 0.10974106041923551, 'fraction_numerical': 0.02404438964241677, 'mean_word_length': 3.204663212435233, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3579186', 'n_tokens_mistral': 633, 'n_tokens_neox': 593, 'n_words': 167}