From: Javier Sancho Date: Sun, 6 Oct 2019 14:59:10 +0000 (+0200) Subject: Return #f if device creation fails X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;ds=sidebyside;h=6926f985d7c92c543969ae8957645815dc58f098;hp=4506d9110b4448ed0fb8c7ea5d1cb4a644801336;p=guile-irrlicht.git Return #f if device creation fails --- diff --git a/examples/hello.scm b/examples/hello.scm index 11c9bb8..283462d 100644 --- a/examples/hello.scm +++ b/examples/hello.scm @@ -20,7 +20,11 @@ (use-modules (irrlicht)) -(define device (create-device 'opengl)) +;; Create device +(define device (create-device 'software '(640 480) 16 #f #f #f)) +(when (not device) + (exit #f)) + (define driver (get-video-driver device)) (define scene-manager (get-scene-manager device)) diff --git a/irrlicht.scm b/irrlicht.scm index 5b405e3..0ff6e3a 100644 --- a/irrlicht.scm +++ b/irrlicht.scm @@ -47,10 +47,11 @@ ('opengl ffi-video:EDT_OPENGL) ('count ffi-video:EDT_COUNT))) (wsize (make-c-struct ffi-core:dimension2d window-size))) - (ffi:create-device driver wsize bits - (if fullscreen 1 0) - (if stencilbuffer 1 0) - (if vsync 1 0)))) + (let ((device (ffi:create-device driver wsize bits + (if fullscreen 1 0) + (if stencilbuffer 1 0) + (if vsync 1 0)))) + (if (null-pointer? device) #f device)))) (define (get-video-driver device) (ffi:get-video-driver device))