From ca784647bc237dd9f9357ade99b507a4a7b2f3e9 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 3 Nov 2019 10:55:22 -0500 Subject: render: model: Move expressions after definitions to fix Guile 2.2 compatibility. --- chickadee/render/model.scm | 82 +++++++++++++++++++++++----------------------- 1 file 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)) -- cgit v1.2.3