 (defmethod update-state :render [command state]
   (next-state state))
 
-(defn render-loop [command-chan pixel-chan]
+(defn render-loop [command-chan render-chan]
   (go-loop [last-state (setup)]
     (let [command (alt!
                     command-chan ([command] command)

      (case (:type command)
        :stop nil
        :render (do
                  (>! pixel-chan (mode/pixel-map (eval-state state)))
                  (recur state))
        (recur state)))))


  (comp
    (map eval-state)
    (map mode/pixel-map)
    (log-framerate 1000)))

(defn -main
  [& args]
  (let [command-chan (chan (buffer 10))
        render-chan (chan (buffer 1) render-pipeline)
        pixel-pusher-chan (fc/start-pushing-pixels render-chan)
        render-loop-chan (render-loop command-chan render-chan)]
    (.addShutdownHook (Runtime/getRuntime)
      (Thread. (fn []
                  (println "\nRecieved shutdown signal. Halting...")
                  (>!! command-chan {:type :stop}))))
    (<!! render-loop-chan)
    (<!! pixel-pusher-chan)))

(println "Alive and kicking!")
