Skip to content

Instantly share code, notes, and snippets.

@Madsy
Last active December 25, 2015 16:39
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/7007230 to your computer and use it in GitHub Desktop.
Save Madsy/7007230 to your computer and use it in GitHub Desktop.
(define modelview (list
(1.0 0.0 0.0 0.0)
(0.0 1.0 0.0 0.0)
(0.0 0.0 1.0 0.0)
(0.0 0.0 0.0 1.0)))
(define projection (list
(1.0 0.0 0.0 0.0)
(0.0 9.0/16.0 0.0 0.0)
(0.0 0.0 1.0 1.0)
(0.0 0.0 0.0 0.0)))
(define m #nil)
(define tex #nil)
(with-mgl
(set! m (mgl-create-mesh-from-file "cube.3ds")) ;encapsulates VBOs, VAO and shader
(set! tex (mgl-create-texture-from-file "cube.png"))
(mgl-enable-blending)
(mgl-enable-depth-test)
(mgl-clear-color (1.0 0.0 0.0 1.0)))
(while (true? running)
(with-mgl
(mgl-clear :color :depth :stencil)
(mgl-use-model m)
(mgl-uniform-matrix "modelview" modelview)
(mgl-uniform-matrix "projection" projection)
(mgl-uniform "rotateVel" 20.0)
(mgl-bind-texture 0 tex) ;bind tex to GL_TEXTURE0. Sampler names follow strict convention
(mgl-render)) ;wrapper for glDrawArrays. Also reads state from bound model m
(mgl-delay 1)) ;ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment