Created
April 13, 2012 09:12
-
-
Save aperiodic/2375349 to your computer and use it in GitHub Desktop.
Classloader changes between defsketch and setup
This file contains hidden or 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
(ns quil-kinect.core | |
(import SimpleOpenNI.SimpleOpenNI) | |
(:use quil.core | |
[quil.applet :only [current-applet applet-close]])) | |
(def kinect (atom nil)) | |
(defn setup [] | |
(let [_ (println (.getClassLoader clojure.lang.IDeref)) | |
kinect-obj (new SimpleOpenNI (current-applet)) | |
_ (println (.getClassLoader clojure.lang.IDeref))] | |
(swap! kinect (fn [_] :totes-a-kinect))) | |
(when-not (.enableDepth @kinect) | |
(throw (new Error (str "Couldn't set up the kinect object! Are you sure " | |
"it's plugged in to both your computer and " | |
"power?"))) | |
(applet-close)) | |
(frame-rate 30)) | |
(defn draw [] | |
(background 0) | |
(.update @kinect) | |
(let [depth-image (.depthImage @kinect)] | |
(image depth-image 0 0))) | |
(println (-> (Thread/currentThread) .getContextClassLoader)) | |
(defsketch kinect | |
:title "Can Haz Kinect!" | |
:setup setup | |
:draw draw | |
:size [640 480]) |
This file contains hidden or 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
[dlp@fiona:~/code/personal/quil-kinect?:0]% lein repl | |
REPL started; server listening on localhost port 46067 | |
user=> (use 'quil-kinect.core) | |
#<DynamicClassLoader clojure.lang.DynamicClassLoader@45c3987> | |
#<AppClassLoader sun.misc.Launcher$AppClassLoader@5ab8df17> | |
SimpleOpenNI Version 0.26 | |
nil | |
user=> #<AppClassLoader sun.misc.Launcher$AppClassLoader@5ab8df17> | |
Exception in thread "Animation Thread" java.lang.ClassCastException: quil.applet.proxy$processing.core.PApplet$IMeta$c5 | |
06c738 cannot be cast to clojure.lang.Atom | |
at clojure.core$swap_BANG_.invoke(core.clj:2106) | |
at quil_kinect.core$setup.invoke(core.clj:12) | |
at clojure.lang.Var.invoke(Var.java:397) | |
at quil.applet$applet$setup_fn__157.invoke(applet.clj:193) | |
at quil.applet$applet$fn__232.invoke(applet.clj:291) | |
at quil.applet.proxy$processing.core.PApplet$IMeta$c506c738.setup(Unknown Source) | |
at processing.core.PApplet.handleDraw(Unknown Source) | |
at quil.applet.proxy$processing.core.PApplet$IMeta$c506c738.handleDraw(Unknown Source) | |
at processing.core.PApplet.run(Unknown Source) | |
at quil.applet.proxy$processing.core.PApplet$IMeta$c506c738.run(Unknown Source) | |
at java.lang.Thread.run(Thread.java:680) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment