Thanks for the idea though.

I'm going through lazyfoo tuts, and making a high level but also really safe 
wrapper while I'm about it.

The high level wrapper builds on top of the really safe low level wrapper I was 
working on before.

So eg, my lazyfoo chapter 01 port looks like this:
    
    
    import ../../my_sdl2_libs/high_level_sdl2
    
    const
      SCREEN_WIDTH = 640
      SCREEN_HEIGHT = 480
      WHITE = (0xFF, 0xFF, 0xFF)
    
    proc main =
      var sdl2_context = initSdl2Context(initvideo=true)
      
      var window = sdl2_context.createWindow(title="SDL Tutorial",
                                             width=SCREEN_WIDTH,
                                             height=SCREEN_HEIGHT,
                                             windowShown=true)
      var screenSurface = window.getSurface()
      screenSurface.fillRect(color=WHITE)
      window.updateSurface()
      sdl2Context.delay(2.0)
    
    main()
    

There's no pointers or references used there, all of those are wrapper objects 
with built-in Nim destructors, so they also automatically tidy their resources 
when they go out of scope.

Also not using OR-based flags, but rather bool arguments.

Nim's named and optional arguments are really awesome, you don't need to use 
builder patterns nearly as much as in some other langs. 

Reply via email to