Created
October 10, 2009 20:35
-
-
Save ztellman/207128 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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