]> git.jsancho.org Git - guile-assimp.git/blob - src/assimp.scm
4ecbcf4e3ff3f1824972d00ded1bbf64e793afd0
[guile-assimp.git] / src / assimp.scm
1 ;;; guile-assimp, foreign interface to libassimp
2 ;;; Copyright (C) 2014 by Javier Sancho Fernandez <jsf at jsancho dot org>
3 ;;;
4 ;;; This program is free software: you can redistribute it and/or modify
5 ;;; it under the terms of the GNU General Public License as published by
6 ;;; the Free Software Foundation, either version 3 of the License, or
7 ;;; (at your option) any later version.
8 ;;;
9 ;;; This program is distributed in the hope that it will be useful,
10 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 ;;; GNU General Public License for more details.
13 ;;;
14 ;;; You should have received a copy of the GNU General Public License
15 ;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17
18 (define-module (assimp assimp)
19   #:use-module (rnrs bytevectors)
20   #:use-module (system foreign))
21
22 (define libassimp (dynamic-link "libassimp"))
23
24 (define aiImportFile
25   (pointer->procedure '*
26                       (dynamic-func "aiImportFile" libassimp)
27                       (list '* unsigned-int)))
28
29 (define-wrapped-pointer-type scene
30   scene?
31   wrap-scene unwrap-scene
32   (lambda (s p)
33     (format p "#<scene ~x>"
34             (pointer-address (unwrap-scene s)))))
35
36 (define (load-scene filename flags)
37   (wrap-scene
38    (aiImportFile (string->pointer filename)
39                  flags)))
40
41 (bytevector-uint-ref (pointer->bytevector numptob (sizeof long))
42                      0 (native-endianness)
43                      (sizeof long))
44
45 (define (scene-contents scene)
46   (bytevector-uint-ref (pointer->bytevector (unwrap-scene scene) 16)
47                        0 (native-endiannes) 4))
48
49 (export load-scene)