Skip to content

Instantly share code, notes, and snippets.

@Aeva
Last active April 2, 2017 03:13
Show Gist options
  • Save Aeva/282135ae7b10e6623dcb76ee89d041f5 to your computer and use it in GitHub Desktop.
Save Aeva/282135ae7b10e6623dcb76ee89d041f5 to your computer and use it in GitHub Desktop.
(use-modules (srfi srfi-1))
(define (camera-layout)
'((matrix #:mat4)))
(define (camera property)
(find (lambda (record) (eq? (car record) property)) (camera-layout)))
(define (model-layout)
'((position #:vec3 #:vertex)
(matrix #:mat4)
(clip-space (* (camera 'matrix) (model 'matrix) (model 'position)))))
(define (model property)
(find (lambda (record) (eq? (car record) property)) (model-layout)))
(define (records) '(camera model))
(define (record? symbol)
(let ([found (find (lambda (name) (eq? name symbol)) (records))])
(cond
[found #t]
[else #f])))
(define (solve thing)
(cond
[(eq? thing '()) '()]
[(and (list? thing) (record? (car thing))) (eval thing (interaction-environment))]
[(list? thing) (cons (solve (car thing)) (solve (cdr thing)))]
[else thing]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment