Skip to content

Instantly share code, notes, and snippets.

@ztellman
Created October 10, 2009 20:35
Show Gist options
  • Save ztellman/207128 to your computer and use it in GitHub Desktop.
Save ztellman/207128 to your computer and use it in GitHub Desktop.
(ns draw-order (:use [penumbra.opengl] [penumbra.window]))
(defn- init [state]
(enable :depth-test)
(ortho-view 0 0 640 480 -1 1)
(scale 1 1 -1)
state)
(defn draw-square [x y w h]
(draw-quads
(vertex x y 0)
(vertex x (+ y h) 0)
(vertex (+ x w) (+ y h) 0)
(vertex (+ x w) y 0)))
(defn- display [[delta time] state]
(let [[x y] [100 100]
[w h] [32 32]
[r g b] [1 0 0]]
(color r g b)
(draw-square x y w h))
(push-matrix
(translate 100 100 -0.5)
(let [[x y] [16 16]
[w h] [32 32]
[r g b] [0 1 0]]
(color r g b)
(draw-square x y w h)))
(push-matrix
(translate 100 100 0.5)
(let [[x y] [-16 -16]
[w h] [32 32]
[r g b] [0 0 1]]
(color r g b)
(draw-square x y w h)))
(write-to-screen (format "%d fps" (int (/ 1 delta))) 0 1)
(repaint))
(def engine {:init init :display display})
(start engine nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment