1 ;;; guile-irrlicht --- FFI bindings for Irrlicht Engine
2 ;;; Copyright (C) 2019 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 ;;; Irrlicht 02.Quake3Map example
22 ;;; http://irrlicht.sourceforge.net/docu/example002.html
25 (use-modules (irrlicht)
28 ;; ask user for driver
30 "Please select the driver you want for this example:
34 (d) Burning's Software Renderer
39 (define driver (match (read-char)
51 ;; start up the engine
55 #:window-size '(640 480)))
59 ;; instances for doing things
60 (define driver (get-video-driver device))
61 (define scene-manager (get-scene-manager device))
62 (define driver-name (get-name driver))
65 (add-file-archive! (get-file-system device) "media/map-20kdm2.pk3")
67 (define mesh (get-mesh scene-manager "20kdm2.bsp"))
68 (define node (add-octree-scene-node!
70 #:minimal-polys-per-node 1024))
71 (set-position! node '(-1300 -144 -1249))
74 (add-camera-scene-node-fps! scene-manager)
75 (set-visible! (get-cursor-control device) #f)
80 (cond ((is-window-active? device)
81 (begin-scene driver #:color '(255 200 200 200))
82 (draw-all scene-manager)
85 (let ((fps (get-fps driver)))
86 (when (not (= last-fps fps))
88 (format #f "Irrlicht Engine - Quake 3 Map example [~a] FPS:~a" driver-name fps)))
89 (set-window-caption! device caption))
90 (set! last-fps fps))))
92 (yield-device device))))