sdl_test.nim 592 B

123456789101112131415161718192021222324252627282930
  1. discard """
  2. action: compile
  3. """
  4. import os
  5. import sdl
  6. if sdl.init(INIT_VIDEO) == -1:
  7. quit("Couldn't initialise SDL")
  8. var window: SdlWindowPtr
  9. var renderer: SdlRendererPtr
  10. if createWindowAndRenderer(640, 480, 0, window, renderer) == -1:
  11. quit("Couldn't create a window or renderer")
  12. discard pollEvent(nil)
  13. renderer.setDrawColor 29, 64, 153, 255
  14. renderer.clear
  15. renderer.setDrawColor 255, 255, 255, 255
  16. var points = [
  17. (260'i32, 320'i32),
  18. (260'i32, 110'i32),
  19. (360'i32, 320'i32),
  20. (360'i32, 110'i32)
  21. ]
  22. renderer.drawLines(addr points[0], points.len.cint)
  23. renderer.present
  24. sleep(5000)