From e01650cfcde81068b3b5819b64f9b641905b3b76 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Mon, 30 Dec 2019 20:45:38 +0100 Subject: [PATCH] Rect foreign record --- examples/01.HelloWorld.scm | 2 +- irrlicht.scm | 1 + irrlicht/bindings/core.scm | 4 ---- irrlicht/device.scm | 2 +- irrlicht/dimension2d.scm | 4 ++-- irrlicht/gui.scm | 3 ++- irrlicht/rect.scm | 41 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 irrlicht/rect.scm diff --git a/examples/01.HelloWorld.scm b/examples/01.HelloWorld.scm index 40b0aca..5a34116 100644 --- a/examples/01.HelloWorld.scm +++ b/examples/01.HelloWorld.scm @@ -42,7 +42,7 @@ (add-static-text! gui-env "Hello World! This is the Irrlicht Software renderer!" - '(10 10 260 22) + (make-rect 10 10 260 22) #:border #t) ;; load a Quake2 model diff --git a/irrlicht.scm b/irrlicht.scm index c70a122..e7dcb4b 100644 --- a/irrlicht.scm +++ b/irrlicht.scm @@ -28,6 +28,7 @@ (irrlicht dimension2d) (irrlicht gui) (irrlicht io) + (irrlicht rect) (irrlicht scene) (irrlicht video))) (current-interface diff --git a/irrlicht/bindings/core.scm b/irrlicht/bindings/core.scm index 8605919..20d8e84 100644 --- a/irrlicht/bindings/core.scm +++ b/irrlicht/bindings/core.scm @@ -22,10 +22,6 @@ #:use-module (system foreign) #:use-module (irrlicht util)) -;; rect struct -(define-public rect - (list int32 int32 int32 int32)) - ;; vector2df struct (define-public vector2df (list float float float)) diff --git a/irrlicht/device.scm b/irrlicht/device.scm index 04b3648..051cddd 100644 --- a/irrlicht/device.scm +++ b/irrlicht/device.scm @@ -52,7 +52,7 @@ ('opengl ffi-video:EDT_OPENGL) ('count ffi-video:EDT_COUNT)))) (let ((device (ffi:create-device driver - (dimension2d-pointer window-size) + (dimension2d->pointer window-size) bits (bool->integer fullscreen) (bool->integer stencilbuffer) diff --git a/irrlicht/dimension2d.scm b/irrlicht/dimension2d.scm index 91de9a4..6b03cd0 100644 --- a/irrlicht/dimension2d.scm +++ b/irrlicht/dimension2d.scm @@ -24,7 +24,7 @@ #:export (dimension2d make-dimension2d dimension2d? - dimension2d-pointer + dimension2d->pointer dimension2d-width dimension2d-height)) @@ -32,6 +32,6 @@ (define-foreign-record-type dimension2d (make-dimension2d width height) dimension2d? - dimension2d-pointer + dimension2d->pointer (width uint32 dimension2d-width) (height uint32 dimension2d-height)) diff --git a/irrlicht/gui.scm b/irrlicht/gui.scm index 0910269..495a9c7 100644 --- a/irrlicht/gui.scm +++ b/irrlicht/gui.scm @@ -23,6 +23,7 @@ #:use-module (system foreign) #:use-module ((irrlicht bindings core) #:prefix ffi-core:) #:use-module ((irrlicht bindings gui) #:prefix ffi-gui:) + #:use-module (irrlicht rect) #:use-module (irrlicht util) #:export (add-static-text! gui-draw-all @@ -37,7 +38,7 @@ (fill-background #f)) (ffi-gui:add-static-text gui-env (string->pointer text) - (make-c-struct ffi-core:rect rectangle) + (rect->pointer rectangle) (bool->integer border) (bool->integer word-wrap) parent diff --git a/irrlicht/rect.scm b/irrlicht/rect.scm new file mode 100644 index 0000000..f481a7c --- /dev/null +++ b/irrlicht/rect.scm @@ -0,0 +1,41 @@ +;;; guile-irrlicht --- FFI bindings for Irrlicht Engine +;;; Copyright (C) 2019 Javier Sancho +;;; +;;; 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 +;;; . + + +(define-module (irrlicht rect) + #:use-module (system foreign) + #:use-module (irrlicht util) + #:export (rect + make-rect + rect? + rect->pointer + rect-x + rect-y + rect-x2 + rect-y2)) + +;; rect struct +(define-foreign-record-type rect + (make-rect x y x2 y2) + rect? + rect->pointer + (x int32 rect-x) + (y int32 rect-y) + (x2 int32 rect-x2) + (y2 int32 rect-y2)) -- 2.39.5