1 ;;; guile-irrlicht --- FFI bindings for Irrlicht Engine
2 ;;; Copyright (C) 2020 Javier Sancho <jsf@jsancho.org>
4 ;;; This file is part of guile-irrlicht.
6 ;;; Guile-irrlicht is free software; you can redistribute it and/or modify
7 ;;; it under the terms of the GNU Lesser General Public License as
8 ;;; published by the Free Software Foundation; either version 3 of the
9 ;;; License, or (at your option) any later version.
11 ;;; Guile-irrlicht is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ;;; General Public License for more details.
16 ;;; You should have received a copy of the GNU Lesser General Public
17 ;;; License along with guile-irrlicht. If not, see
18 ;;; <http://www.gnu.org/licenses/>.
21 (define-module (irrlicht device)
22 #:use-module (oop goops)
23 #:use-module (irrlicht base)
24 #:use-module (irrlicht foreign)
25 #:use-module ((irrlicht irr) #:select (<event-receiver> <reference-counted>)))
29 (define-class <irrlicht-device> (<reference-counted>)
30 (irr-class #:init-value "IrrlichtDevice"))
32 (define* (create-device #:key
33 (device-type 'software)
34 (window-size '(640 480))
39 (receiver (make <event-receiver>)))
40 (if (not (is-a? receiver <event-receiver>))
42 "In procedure create-device: Wrong type argument (expecting <event-receiver>):"
45 (let* ((createDevice (get-irrlicht-proc "createDevice"))
46 (device (createDevice device-type window-size bits fullscreen stencilbuffer
48 (cond ((null-object? device)
49 (error "In procedure create-device: Device cannot be created"))
53 (define-method (get-cursor-control (device <irrlicht-device>))
54 (let ((getCursorControl (get-irrlicht-proc "getCursorControl" device)))
55 (getCursorControl device)))
57 (define-method (get-file-system (device <irrlicht-device>))
58 (let ((getFileSystem (get-irrlicht-proc "getFileSystem" device)))
59 (getFileSystem device)))
61 (define-method (get-gui-environment (device <irrlicht-device>))
62 (let ((getGUIEnvironment (get-irrlicht-proc "getGUIEnvironment" device)))
63 (getGUIEnvironment device)))
65 (define-method (get-scene-manager (device <irrlicht-device>))
66 (let ((getSceneManager (get-irrlicht-proc "getSceneManager" device)))
67 (getSceneManager device)))
69 (define-method (get-timer (device <irrlicht-device>))
70 (let ((getTimer (get-irrlicht-proc "getTimer" device)))
73 (define-method (get-video-driver (device <irrlicht-device>))
74 (let ((getVideoDriver (get-irrlicht-proc "getVideoDriver" device)))
75 (getVideoDriver device)))
77 (define-method (is-window-active? (device <irrlicht-device>))
78 (let ((isWindowActive (get-irrlicht-proc "isWindowActive" device)))
79 (isWindowActive device)))
81 (define-method (run (device <irrlicht-device>))
82 ((get-irrlicht-proc "run" device) device))
84 (define-method (set-resizable! (device <irrlicht-device>) resize)
85 (let ((setResizable (get-irrlicht-proc "setResizable" device)))
86 (setResizable device resize)))
88 (define-method (set-window-caption! (device <irrlicht-device>) text)
89 ((get-irrlicht-proc "setWindowCaption" device)
92 (define-method (yield-device (device <irrlicht-device>))
93 (let ((yield (get-irrlicht-proc "yield" device)))
96 (export <irrlicht-device> create-device get-cursor-control get-file-system get-gui-environment
97 get-scene-manager get-timer get-video-driver is-window-active? run set-resizable!
98 set-window-caption! yield-device)