Skip to content

Instantly share code, notes, and snippets.

@rosado
Created February 15, 2012 18:41
Show Gist options
  • Save rosado/1838069 to your computer and use it in GitHub Desktop.
Save rosado/1838069 to your computer and use it in GitHub Desktop.
example opengl code for clj-processing
;; processing example
(ns mouse-example-3d
(:use [rosado.processing]
[rosado.processing.applet]))
(def mouse-position (atom [0 0]))
(defn draw
[]
(background-float 125)
(let [[x y] @mouse-position]
(with-translation [x y 0.0]
(sphere 24.0))))
(defn setup []
(size 200 200 OPENGL)
(lights)
(smooth)
(no-stroke))
(defn mouse-moved [evt]
(let [x (.getX evt) y (.getY evt)]
(reset! mouse-position [x y])))
;; Now we just need to define an applet:
(defapplet mouse-example :title "Mouse example."
:size [200 200]
:setup setup
:draw draw
:mouse-moved mouse-moved)
(run mouse-example)
;; (stop mouse-example)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment