            (org.lwjgl.opengl Display GL11)
            (org.lwjgl BufferUtils)))
 
+(def enable-display-text true)
 (def #^:dynamic *gui-state* (atom {:rotate-mode :none :translate-mode :none                                    
                                    :rot-x 0 :rot-y 0 :rot-z 0
                                    :shift-x 0 :shift-y -20 :shift-z -50;-30                                   

#_"This file is part of brevis.                                                                                                                                                 
                                                                                                                                                                                     
    Ekman's Garden is free software: you can redistribute it and/or modify                                                                                                           
    it under the terms of the GNU General Public License as published by                                                                                                             
    the Free Software Foundation, either version 3 of the License, or                                                                                                                
    (at your option) any later version.                                                                                                                                              
                                                                                                                                                                                     
    Ekman's Garden is distributed in the hope that it will be useful,                                                                                                                
    but WITHOUT ANY WARRANTY; without even the implied warranty of                                                                                                                   
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                                                                                                    
    GNU General Public License for more details.                                                                                                                                     
                                                                                                                                                                                     
    You should have received a copy of the GNU General Public License                                                                                                                
    along with Ekman's Garden.  If not, see <http://www.gnu.org/licenses/>.                                                                                                          
                                                                                                                                                                                     
Copyright 2012, 2013 Kyle Harrington"     


(defn mouse-drag
  "Rotate the world."
  [[dx dy] _ button state]
  (let [rads (/ (Math/PI) 180)
        thetaY (*(:rot-y state) rads)
        sY (sin thetaY)
        cY (cos thetaY)
        thetaX (* (:rot-x state) rads)
        sX (sin thetaX)
        cX (cos thetaX)]  
	  (when @shift-key-down
	    (cond 
	      ; Rotate
	      (= :left button)
	      (swap! *gui-state* assoc
	             :rot-x (+ (:rot-x @*gui-state*) dy)
	             :rot-y (+ (:rot-y @*gui-state*) dx))
	      (= :right button)
	      (swap! *gui-state* assoc
	             :shift-x (+ (:shift-x @*gui-state*) (* dx cY))
	             :shift-y (- (:shift-y @*gui-state*) (* dy cX))
	             :shift-z (+ (:shift-z @*gui-state*) (* dx sY))
	             )
	      ; Zoom
	      (= :center button)
	      (swap! *gui-state* assoc
	             :shift-x (+ (:shift-x @*gui-state*) (* (/ dy 6) (* sY -1)))
	             :shift-y (+ (:shift-y @*gui-state*) (* (/ dy 6) sX))
	             :shift-z (+ (:shift-z @*gui-state*) (* (/ dy 6) cY))           
	             ))))
  state)

(defn mouse-wheel
  "Respond to a mousewheel movement. dw is +/- depending on scroll-up or down."
  [dw state]
  (let [rads (/ (Math/PI) 180)
        thetaY (*(:rot-y state) rads)
        sY (sin thetaY)
        cY (cos thetaY)
        thetaX (* (:rot-x state) rads)
        sX (sin thetaX)
        cX (cos thetaX)]
  (swap! *gui-state* assoc
						         :shift-z (+ (:shift-z @*gui-state*) (* (/ dw 6) cY))
						         :shift-x (+ (:shift-x @*gui-state*) (* (/ dw 6) (* sY -1)))
						         :shift-y (+ (:shift-y @*gui-state*) (* (/ dw 6) sX)))
  state))

(defn mouse-move
  "Respond to a change in x,y position of the mouse."
