]> git.jsancho.org Git - guile-irrlicht.git/blobdiff - irrlicht.scm
Return #f if device creation fails
[guile-irrlicht.git] / irrlicht.scm
index 6e7ccff6377958b42260471b1c6e64f599eee171..0ff6e3a6083358af344f25911a9f21b2be555abb 100644 (file)
@@ -27,7 +27,9 @@
   #:export (create-device
             get-video-driver
             get-scene-manager
-            set-window-caption!))
+            set-window-caption!
+            device-run?
+            device-drop!))
 
 (define* (create-device #:optional
                         (device-type 'software)
                        ('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))
@@ -58,3 +61,9 @@
 
 (define (set-window-caption! device text)
   (ffi:set-window-caption device (string->pointer text)))
+
+(define (device-run? device)
+  (if (> (ffi:run device) 0) #t #f))
+
+(define (device-drop! device)
+  (if (> (ffi:drop device) 0) #t #f))