Skip to content

Commit

Permalink
less cleverness for #3
Browse files Browse the repository at this point in the history
  • Loading branch information
swannodette committed May 8, 2010
1 parent 57247af commit 154f9a0
Showing 1 changed file with 20 additions and 26 deletions.
46 changes: 20 additions & 26 deletions src/clj_nehe/tutorial3.clj
Expand Up @@ -6,28 +6,21 @@
;; -----------------------------------------------------------------------------
;; Vars

(def *width* 640)
(def *height* 480)

(def *tri* [[1 0 0] ; color, red
[0 1 0] ; vertex
[0 1 0] ; color, green
[-1 -1 0] ; vertex
[0 0 1] ; color, blue
[1 -1 0]] ; vertex
(def app-width 640)
(def app-height 480)

(def tri [[1 0 0] ; color, red
[0 1 0] ; vertex
[0 1 0] ; color, green
[-1 -1 0] ; vertex
[0 0 1] ; color, blue
[1 -1 0]] ; vertex
)

(def *quad* [[-1 1 0]
[1 1 0]
[1 -1 0]
[-1 -1 0]])

;; -----------------------------------------------------------------------------
;; Helpers

(defn color-and-vertex [[a b]]
(apply color a)
(apply vertex b))
(def quad [[-1 1 0]
[1 1 0]
[1 -1 0]
[-1 -1 0]])

;; -----------------------------------------------------------------------------
;; Import
Expand All @@ -40,7 +33,7 @@
(defn init [state]
(app/title! "Nehe Tutorial 3")
(app/vsync! false)
(app/display-mode! *width* *height*)
(app/display-mode! app-width app-height)
(shade-model :smooth)
(clear-color 0 0 0 0.5)
(clear-depth 1)
Expand All @@ -50,8 +43,8 @@
(assoc state :fullscreen false))

(defn reshape [[x y width height] state]
(viewport 0 0 *width* *height*)
(frustum-view 45 (/ (double *width*) *height*) 0.1 100)
(viewport 0 0 app-width app-height)
(frustum-view 45 (/ (double app-width) app-height) 0.1 100)
(load-identity)
state)

Expand All @@ -65,12 +58,13 @@
(defn display [[delta time] state]
(translate -1.5 0 -6)
(draw-triangles
(doall
(map color-and-vertex (partition 2 *tri*))))
(doseq [[c v] (partition 2 tri)]
(apply color c)
(apply vertex v)))
(translate 3 0 0)
(color 0.5 0.5 1)
(draw-quads
(doall (map #(apply vertex %) *quad*)))
(doall (map #(apply vertex %) quad)))
(app/repaint!))

(defn display-proxy [& args]
Expand Down

0 comments on commit 154f9a0

Please sign in to comment.