From 6926f985d7c92c543969ae8957645815dc58f098 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Sun, 6 Oct 2019 16:59:10 +0200 Subject: [PATCH] Return #f if device creation fails --- examples/hello.scm | 6 +++++- irrlicht.scm | 9 +++++---- 2 files changed, 10 insertions(+), 5 deletions(-) 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)) -- 2.39.5