Skip to content

Instantly share code, notes, and snippets.

@Madsy
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Madsy/9712545 to your computer and use it in GitHub Desktop.
Save Madsy/9712545 to your computer and use it in GitHub Desktop.
(define-module (lambda-demo opengl enums)
#:use-module (rnrs bytevectors)
#:export (gl-enum))
(eval-when (expand load eval)
(define *gl-enums*
'((depth-buffer-bit . #x100 )
(stencil-buffer-bit . #x400 )
(color-buffer-bit . #x4000 )
(false . #x0 )
(true . #x1 )
(points . #x0 )
(lines . #x1 )
(line-loop . #x2 )
(line-strip . #x3 )
(triangles . #x4 )
(triangle-strip . #x5 )
(triangle-fan . #x6 )
(quads . #x7 )
(mirror-clamp-to-edge . #x8743 ))))
;(define-syntax-rule (gl-enum enum)
; (cdr (assq enum *gl-enums*)))
(define-syntax gl-enum
(lambda (form)
(syntax-case form ()
((gl-enum kw)
(let ((val (assq-ref *gl-enums* (syntax->datum #'kw))))
(if val
(datum->syntax #'kw val)
(syntax-violation 'gl-enum "unknown keyword" form)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment