diff options
author | David Thompson <dthompson2@worcester.edu> | 2015-12-14 12:09:48 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2015-12-14 12:09:48 -0500 |
commit | d4c076cf2359bace62975cd2cae0d94b1c477ae5 (patch) | |
tree | fd8365e28b87535c2c90fdc425c768050b2ae132 /examples/hello.scm | |
parent | c63c46573ac88961c4e33556a77dc6fe5dca528c (diff) |
example: Use the "call-with-*" procedures to manage resources.
Diffstat (limited to 'examples/hello.scm')
-rw-r--r-- | examples/hello.scm | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/examples/hello.scm b/examples/hello.scm index 1f98669..d45c804 100644 --- a/examples/hello.scm +++ b/examples/hello.scm @@ -22,17 +22,18 @@ (sdl2 surface) (sdl2 video)) +(define (draw ren) + (let* ((surface (load-bmp "hello.bmp")) + (texture (surface->texture ren surface))) + (clear-renderer ren) + (render-copy ren texture) + (present-renderer ren) + (sleep 2))) + (sdl-init) -(define window (make-window)) -(define ren (make-renderer window)) -(define surface (load-bmp "hello.bmp")) -(define texture (surface->texture ren surface)) +(call-with-window (make-window) + (lambda (window) + (call-with-renderer (make-renderer window) draw))) -(clear-renderer ren) -(render-copy ren texture) -(present-renderer ren) -(sleep 2) -(close-window! window) -(delete-renderer! ren) (sdl-quit) |