LoginSignup
0
0

More than 5 years have passed since last update.

Nim in Action SDL sample written with official SDL wrapper

Last updated at Posted at 2018-08-30

The example of SDL wrapping described in Nim in Action works fine in the self-made wrapper but not on https://github.com/nim-lang/sdl2.
Replacing it with the following would work.

import sdl2
import os

if init(INIT_VIDEO) == SdlError:
  quit("Couldn't initialise SDL")

var
  window: WindowPtr
  renderer: RendererPtr
  evt = defaultEvent
if createWindowAndRenderer(640, 480, 0, window, renderer) == SdlError:
  quit("Counldn't create a window or renderer")

discard pollEvent(evt)
renderer.setDrawColor 27,64,153,255
renderer.clear

renderer.setDrawColor 255,255,255,255

var point = [
  (260'i32, 320'i32),
  (260'i32, 110'i32),
  (360'i32, 320'i32),
  (360'i32, 110'i32),
]

renderer.drawLines(addr point[0], point.len.cint)
renderer.present
sleep(5000)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0