#:use-module ((irrlicht bindings) #:prefix ffi:)
#:use-module ((irrlicht bindings core) #:prefix ffi-core:)
#:use-module ((irrlicht bindings video) #:prefix ffi-video:)
+ #:use-module (irrlicht util)
#:export (create-device
get-cursor-control
get-file-system
('count ffi-video:EDT_COUNT)))
(wsize (make-c-struct ffi-core:dimension2d window-size)))
(let ((device (ffi:create-device driver wsize bits
- (if fullscreen 1 0)
- (if stencilbuffer 1 0)
- (if vsync 1 0))))
+ (bool->integer fullscreen)
+ (bool->integer stencilbuffer)
+ (bool->integer vsync))))
(if (null-pointer? device) #f device))))
(define (get-cursor-control device)
(ffi:get-scene-manager device))
(define (is-window-active? device)
- (if (> (ffi:is-window-active device) 0) #t #f))
+ (integer->bool (ffi:is-window-active device)))
(define (set-window-caption! device text)
(ffi:set-window-caption device (string->pointer text)))
(define (device-run? device)
- (if (> (ffi:run device) 0) #t #f))
+ (integer->bool (ffi:run device)))
(define (device-drop! device)
- (if (> (ffi:drop device) 0) #t #f))
+ (integer->bool (ffi:drop device)))
#:use-module (system foreign)
#:use-module ((irrlicht bindings core) #:prefix ffi-core:)
#:use-module ((irrlicht bindings gui) #:prefix ffi-gui:)
+ #:use-module (irrlicht util)
#:export (add-static-text!
gui-draw-all
set-visible-cursor!))
(ffi-gui:add-static-text gui-env
(string->pointer text)
(make-c-struct ffi-core:rect rectangle)
- (if border 1 0)
- (if word-wrap 1 0)
+ (bool->integer border)
+ (bool->integer word-wrap)
parent
id
- (if fill-background 1 0)))
+ (bool->integer fill-background)))
(define (gui-draw-all gui-env)
(ffi-gui:draw-all gui-env))
(define (set-visible-cursor! cursor-control visible)
(ffi-gui:set-visible-cursor
cursor-control
- (if visible 1 0)))
+ (bool->integer visible)))
#:use-module (ice-9 match)
#:use-module (system foreign)
#:use-module ((irrlicht bindings io) #:prefix ffi-io:)
+ #:use-module (irrlicht util)
#:export (add-file-archive!))
(define* (add-file-archive! file-system filename
('unknown ffi-io:EFAT_UNKNOWN))))
(ffi-io:add-file-archive file-system
(string->pointer filename)
- (if ignore-case 1 0)
- (if ignore-paths 1 0)
+ (bool->integer ignore-case)
+ (bool->integer ignore-paths)
type
(string->pointer password)
ret-archive)))
#:use-module ((irrlicht bindings core) #:prefix ffi-core:)
#:use-module ((irrlicht bindings scene) #:prefix ffi-scene:)
#:use-module ((irrlicht bindings video) #:prefix ffi-video:)
+ #:use-module (irrlicht util)
#:export (add-animated-mesh-scene-node
add-camera-scene-node
add-camera-scene-node-fps!
(make-c-struct ffi-core:vector3df position)
(make-c-struct ffi-core:vector3df rotation)
(make-c-struct ffi-core:vector3df scale)
- (if also-add-if-mesh-pointer-zero 1 0))))
+ (bool->integer also-add-if-mesh-pointer-zero))))
(if (null-pointer? node) #f node)))
(define* (add-camera-scene-node scene-manager
(make-c-struct ffi-core:vector3df position)
(make-c-struct ffi-core:vector3df lookat)
id
- (if make-active 1 0))))
+ (bool->integer make-active))))
(if (null-pointer? camera) #f camera)))
(define* (add-camera-scene-node-fps! scene-manager
id
key-map-array
key-map-size
- (if no-vertical-movement 1 0)
+ (bool->integer no-vertical-movement)
jump-speed
- (if invert-mouse 1 0)
- (if make-active 1 0)))
+ (bool->integer invert-mouse)
+ (bool->integer make-active)))
(define* (add-octree-scene-node-am scene-manager mesh
#:key
parent
id
minimal-polys-per-node
- (if also-add-if-mesh-pointer-zero 1 0)))
+ (bool->integer also-add-if-mesh-pointer-zero)))
(define (get-mesh scene-manager filename)
(let ((mesh (ffi-scene:get-mesh scene-manager (string->pointer filename))))
(ffi-scene:set-material-flag-am
node
material-flag
- (if newvalue 1 0))))
+ (bool->integer newvalue))))
(define (set-material-texture-am! node texture-layer texture)
(ffi-scene:set-material-texture-am node texture-layer texture))
--- /dev/null
+;;; guile-irrlicht --- FFI bindings for Irrlicht Engine
+;;; Copyright (C) 2019 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 util)
+ #:export (bool->integer
+ integer->bool))
+
+(define (bool->integer var)
+ (if var 1 0))
+
+(define (integer->bool var)
+ (if (= var 0) #f #t))
#:use-module (system foreign)
#:use-module ((irrlicht bindings core) #:prefix ffi-core:)
#:use-module ((irrlicht bindings video) #:prefix ffi-video:)
+ #:use-module (irrlicht util)
#:export (begin-scene
end-scene
get-fps
(video-data %null-pointer)
(source-rect '()))
(ffi-video:begin-scene driver
- (if back-buffer 1 0)
- (if z-buffer 1 0)
+ (bool->integer back-buffer)
+ (bool->integer z-buffer)
(make-c-struct ffi-video:scolor color)
video-data
(if (null? source-rect)