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 video)
22 #:use-module (oop goops)
23 #:use-module (ice-9 optargs)
24 #:use-module (irrlicht base)
25 #:use-module (irrlicht foreign))
29 (define-class <texture> (<irrlicht-base>)
30 (irr-class #:init-value "ITexture"))
36 (define-class <video-driver> (<irrlicht-base>)
37 (irr-class #:init-value "IVideoDriver"))
39 (define-method (begin-scene (video-driver <video-driver>) . rest)
46 ((get-irrlicht-proc "beginScene" video-driver)
54 (define-method (end-scene (video-driver <video-driver>))
55 ((get-irrlicht-proc "endScene" video-driver)
58 (define-method (get-fps (video-driver <video-driver>))
59 (let ((getFPS (get-irrlicht-proc "getFPS" video-driver)))
60 (getFPS video-driver)))
62 (define-method (get-name (video-driver <video-driver>))
63 (let ((getName (get-irrlicht-proc "getName" video-driver)))
64 (getName video-driver)))
66 (define-method (get-texture (video-driver <video-driver>) filename)
69 ((get-irrlicht-proc "getTexture" video-driver)
73 (export <video-driver> begin-scene end-scene get-fps get-name get-texture)
77 (define-class <vertex3d> (<irrlicht-base>)
78 (irr-class #:init-value "S3DVertex"))
80 (define-method (get-position (vertex3d <vertex3d>))
81 (let ((S3DVertex_Pos (get-irrlicht-proc "S3DVertex_Pos")))
82 (S3DVertex_Pos vertex3d)))
84 (define (make-vertex3d position normal color tcoords)
85 (let ((S3DVertex_make (get-irrlicht-proc "S3DVertex_make")))
88 (S3DVertex_make position normal color tcoords))))
90 (export <vertex3d> get-position make-vertex3d)
94 (define-class <material> (<irrlicht-base>)
95 (irr-class #:init-value "SMaterial"))
97 (define* (make-material #:key
98 (material-type 'solid)
99 (ambient-color '(255 255 255 255))
100 (diffuse-color '(255 255 255 255))
101 (emissive-color '(0 0 0 0))
102 (specular-color '(255 255 255 255))
104 (material-type-param 0)
105 (material-type-param-2 0)
107 (z-buffer 'less-equal)
108 (anti-aliasing 'simple)
110 (color-material 'diffuse)
111 (blend-operation 'none)
112 (polygon-offset-factor 0)
113 (polygon-offset-direction 'front)
119 (backface-culling #t)
120 (frontface-culling #f)
122 (normalize-normals #f)
124 (let ((SMaterial_make (get-irrlicht-proc "SMaterial_make")))
127 (SMaterial_make #:material-type material-type #:ambient-color ambient-color
128 #:diffuse-color diffuse-color #:emissive-color emissive-color
129 #:specular-color specular-color #:shininess shininess
130 #:material-type-param material-type-param
131 #:material-type-param-2 material-type-param-2
132 #:thickness thickness #:z-buffer z-buffer #:anti-aliasing anti-aliasing
133 #:color-mask color-mask #:color-material color-material
134 #:blend-operation blend-operation
135 #:polygon-offset-factor polygon-offset-factor
136 #:polygon-offset-direction polygon-offset-direction
137 #:wireframe wireframe #:point-cloud point-cloud
138 #:gouraud-shading gouraud-shading #:lighting lighting
139 #:z-write-enable z-write-enable #:backface-culling backface-culling
140 #:frontface-culling frontface-culling #:fog-enable fog-enable
141 #:normalize-normals normalize-normals #:use-mip-maps use-mip-maps))))
143 (export <material> make-material)