Created
February 15, 2012 18:41
-
-
Save rosado/1838069 to your computer and use it in GitHub Desktop.
example opengl code for clj-processing
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
;; 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