summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2019-11-03 10:55:22 -0500
committerDavid Thompson <dthompson2@worcester.edu>2019-11-03 10:55:22 -0500
commitca784647bc237dd9f9357ade99b507a4a7b2f3e9 (patch)
treed1289cc918f26ba21e96445d78178895e0616a7e
parentec15aa537055159fc94f667a9219dde27deefb89 (diff)
render: model: Move expressions after definitions to fix Guile 2.2 compatibility.
-rw-r--r--chickadee/render/model.scm82
1 files changed, 41 insertions, 41 deletions
diff --git a/chickadee/render/model.scm b/chickadee/render/model.scm
index 9f29240..56f5c39 100644
--- a/chickadee/render/model.scm
+++ b/chickadee/render/model.scm
@@ -487,47 +487,6 @@
(loop a c rest #t))))))
(_
(parse-error "invalid face" args))))
- ;; Register default material
- (hash-set! material-map "default" default-phong-material)
- ;; Parse file.
- (let loop ((material "default"))
- (match (read-line port)
- ((? eof-object?)
- #f)
- (line
- (match (delete "" (string-split line char-set:whitespace))
- ((or () ("#" . _)) ; ignore comments and blank lines
- (loop material))
- (("f" . args)
- (parse-face args material)
- (loop material))
- (("g" . _) ; ignore group name for now
- (loop material))
- (("mtllib" mtl-file-name)
- (load-mtl (scope-file mtl-file-name))
- (loop material))
- (("o" . _) ;ignore object name for now
- (loop material))
- (("s" . _) ; ignore smoothing group for now
- (loop material))
- (("usemtl" new-material)
- (loop new-material))
- (("v" . args)
- (parse-vertex args)
- (loop material))
- (("vn" . args)
- (parse-normal args)
- (loop material))
- (("vt" . args)
- (parse-texcoord args)
- (loop material))
- (data
- (format (current-error-port)
- "warning: ~a:~d: unsupported OBJ data: ~s~%"
- file-name
- (port-line port)
- data)
- (loop material))))))
;; Build a vertex array for all the faces of a single
;; material.
;;
@@ -603,6 +562,47 @@
(2 . ,normal-view)))
(or (hash-ref material-map material)
(hash-ref material-map "default"))))))
+ ;; Register default material
+ (hash-set! material-map "default" default-phong-material)
+ ;; Parse file.
+ (let loop ((material "default"))
+ (match (read-line port)
+ ((? eof-object?)
+ #f)
+ (line
+ (match (delete "" (string-split line char-set:whitespace))
+ ((or () ("#" . _)) ; ignore comments and blank lines
+ (loop material))
+ (("f" . args)
+ (parse-face args material)
+ (loop material))
+ (("g" . _) ; ignore group name for now
+ (loop material))
+ (("mtllib" mtl-file-name)
+ (load-mtl (scope-file mtl-file-name))
+ (loop material))
+ (("o" . _) ;ignore object name for now
+ (loop material))
+ (("s" . _) ; ignore smoothing group for now
+ (loop material))
+ (("usemtl" new-material)
+ (loop new-material))
+ (("v" . args)
+ (parse-vertex args)
+ (loop material))
+ (("vn" . args)
+ (parse-normal args)
+ (loop material))
+ (("vt" . args)
+ (parse-texcoord args)
+ (loop material))
+ (data
+ (format (current-error-port)
+ "warning: ~a:~d: unsupported OBJ data: ~s~%"
+ file-name
+ (port-line port)
+ data)
+ (loop material))))))
;; Construct a mesh by composing primitives. One primitive
;; per material.
(let* ((model-name (basename file-name))