]> git.jsancho.org Git - guile-irrlicht.git/blobdiff - irrlicht/device.scm
add-static-text!
[guile-irrlicht.git] / irrlicht / device.scm
diff --git a/irrlicht/device.scm b/irrlicht/device.scm
new file mode 100644 (file)
index 0000000..6049016
--- /dev/null
@@ -0,0 +1,73 @@
+;;; guile-irrlicht --- FFI bindings for Irrlicht Engine
+;;; Copyright (C) 2020 Javier Sancho <jsf@jsancho.org>
+;;;
+;;; This file is part of guile-irrlicht.
+;;;
+;;; Guile-irrlicht is free software; you can redistribute it and/or modify
+;;; it under the terms of the GNU Lesser General Public License as
+;;; published by the Free Software Foundation; either version 3 of the
+;;; License, or (at your option) any later version.
+;;;
+;;; Guile-irrlicht is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU Lesser General Public
+;;; License along with guile-irrlicht.  If not, see
+;;; <http://www.gnu.org/licenses/>.
+
+
+(define-module (irrlicht device)
+  #:use-module (oop goops)
+  #:use-module (irrlicht base)
+  #:use-module (irrlicht foreign)
+  #:use-module (irrlicht irr)
+  #:use-module (irrlicht gui)
+  #:use-module (irrlicht scene)
+  #:use-module (irrlicht video))
+
+
+;; IrrlichtDevice
+(define-class <irrlicht-device> (<reference-counted>))
+
+(define* (create-device #:key
+                        (device-type 'software)
+                        (window-size '(640 480))
+                        (bits 16)
+                        (fullscreen #f)
+                        (stencilbuffer #f)
+                        (vsync #f)
+                        (receiver (make <event-receiver>)))
+  (if (not (is-a? receiver <event-receiver>))
+      (error
+       "In procedure create-device: Wrong type argument (expecting <event-receiver>):"
+       receiver))
+
+  (make <irrlicht-device>
+    #:irr-pointer
+    (irr_createDevice
+     device-type
+     window-size
+     bits
+     fullscreen
+     stencilbuffer
+     vsync
+     (irr-pointer receiver))))
+
+(define-method (get-gui-environment (device <irrlicht-device>))
+  (make <gui-environment>
+    #:irr-pointer (irr_IrrlichtDevice_getGUIEnvironment (irr-pointer device))))
+
+(define-method (get-scene-manager (device <irrlicht-device>))
+  (make <scene-manager>
+    #:irr-pointer (irr_IrrlichtDevice_getSceneManager (irr-pointer device))))
+
+(define-method (get-video-driver (device <irrlicht-device>))
+  (make <video-driver>
+    #:irr-pointer (irr_IrrlichtDevice_getVideoDriver (irr-pointer device))))
+
+(define-method (set-window-caption! (device <irrlicht-device>) text)
+  (irr_IrrlichtDevice_setWindowCaption (irr-pointer device) text))
+
+(export create-device get-gui-environment get-scene-manager get-video-driver set-window-caption!)