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 (define-module (irrlicht video)
22 #:use-module (system foreign)
23 #:use-module ((irrlicht bindings core) #:prefix ffi-core:)
24 #:use-module ((irrlicht bindings video) #:prefix ffi-video:)
25 #:use-module (irrlicht util)
26 #:use-module (irrlicht util foreign)
37 (define* (begin-scene driver
42 (video-data %null-pointer)
44 (ffi-video:begin-scene driver
45 (bool->integer back-buffer)
46 (bool->integer z-buffer)
47 (ffi-video:scolor->pointer color)
49 (if (null? source-rect)
51 (ffi-core:rect->pointer source-rect))))
53 (define (end-scene driver)
54 (ffi-video:end-scene driver))
56 (define (get-fps driver)
57 (ffi-video:get-fps driver))
59 (define (get-texture driver filename)
60 (ffi-video:get-texture driver (string->pointer filename)))
62 (define (get-video-driver-name driver)
64 (ffi-video:get-video-driver-name driver)))
66 (define (set-material! driver material)
67 (ffi-video:set-material
69 (ffi-video:smaterial->pointer material)))
72 (define (make-s3dvertex position normal color t-coords)
73 (ffi-video:pointer->s3dvertex
74 (make-c-struct ffi-video:s3dvertex
75 (list position normal color t-coords))))
77 (define (vertex-position vertex)
78 (let ((data (parse-c-struct (ffi-video:s3dvertex->pointer vertex)
79 ffi-video:s3dvertex)))
83 (define* (make-material #:key (wireframe #f) (lighting #t))
87 (list %null-pointer 0 0 0 0 0 0 %null-pointer %null-pointer)
88 (list %null-pointer 0 0 0 0 0 0 %null-pointer %null-pointer)
89 (list %null-pointer 0 0 0 0 0 0 %null-pointer %null-pointer)
90 (list %null-pointer 0 0 0 0 0 0 %null-pointer %null-pointer)
91 ffi-video:EMT_SOLID ; materialType
92 (list 255 255 255 255) ; ambientColor
93 (list 255 255 255 255) ; diffuseColor
94 (list 0 0 0 0) ; emissiveColor
95 (list 255 255 255 255) ; specularColor
98 0 ; materialTypeParam2
100 ffi-video:ECFN_LESSEQUAL ; zBuffer
101 ffi-video:EAAM_SIMPLE ; antiAliasing
103 ffi-video:ECP_ALL ; colorMask
104 ffi-video:ECM_DIFFUSE ; colorMaterial
105 ffi-video:EBO_NONE ; blendOperation
106 0 ; polygonOffsetFactor
107 ffi-video:EPO_FRONT ; polygonOffsetDirection
108 (bool->integer wireframe) ; wireframe
109 (bool->integer #f) ; pointCloud
110 (bool->integer #t) ; gouraudShading
111 (bool->integer lighting) ; lighting
112 (bool->integer #t) ; zWriteEnable
113 (bool->integer #t) ; backfaceCulling
114 (bool->integer #f) ; frontfaceCulling
115 (bool->integer #f) ; fogEnable
116 (bool->integer #f) ; normalizeNormals
117 (bool->integer #t) ; useMipMaps
119 (ffi-video:pointer->smaterial
120 (make-c-struct+ ffi-video:smaterial material))))