Using Quil as a library, instance many sketches

105 views
Skip to first unread message

Alex Fowler

unread,
Jul 23, 2015, 1:43:43 PM7/23/15
to clj-processing
I am writing software with JMonkeyEngine3 and using Processing to create dynamically rendered textures. There is no problem, I can create as many PApplets as I want, but with Quil it seems to be not a straightforward thing to do, since it supposes that I want only 1 instance of a single app and that's it. And it is not clear how to better integrate it with the rest of my app.

Are there any recommendations on how to create and handle multiple simultaneously running sketches within a bigger program? Currently I can only think of creating many PGraphics instances within a single Quil applet, have separate functions on rendering to them, and feeding their content to the textures - alright, but how do I suppress Quil creating the separate window?

Any ideas along these lines are welcome!

Nikita Beloglazov

unread,
Jul 23, 2015, 2:00:30 PM7/23/15
to clj-processing
Hi Alex

You can create multiple sketches with quil too. Just use (q/sketch) instead of (q/defsketch). I think there is no global variables that prevent having more than 1 concurrent sketch. Also (q/sketch) returns you the applet which you can store or manipulate, e.g. close it. 

--
You received this message because you are subscribed to the Google Groups "clj-processing" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clj-processin...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Fowler

unread,
Jul 25, 2015, 6:48:27 PM7/25/15
to clj-processing, nikela...@gmail.com
Hi ,NIkita!

Alright, so I've got them now. One small issue stil persists though: Quil keeps creating windows for every sketch... That does not happen when I create a PApplet and them run it directly with Java Processing. Is it possible to make it stop doing this?


четверг, 23 июля 2015 г., 22:00:30 UTC+4 пользователь Nikita Beloglazov написал:

Alex Fowler

unread,
Jul 26, 2015, 5:33:57 AM7/26/15
to clj-processing, nikela...@gmail.com
Well, I have looked at the source and found that there is a call to PApplet/runSketch which runs the frame.. I guess, I'll have to code around it to get rid of this. I think I can just patch the quil.core ns to be less definitive about making the window...


четверг, 23 июля 2015 г., 22:00:30 UTC+4 пользователь Nikita Beloglazov написал:
Hi Alex

Alex Fowler

unread,
Jul 26, 2015, 5:35:41 AM7/26/15
to clj-processing, nikela...@gmail.com, alex.m...@gmail.com
Sorry, meant "patch quil.applet", not "quil.core".

воскресенье, 26 июля 2015 г., 13:33:57 UTC+4 пользователь Alex Fowler написал:

Nikita Beloglazov

unread,
Jul 26, 2015, 2:08:37 PM7/26/15
to Alex Fowler, clj-processing
Sure. There is also :features [:no-start] option which works only for clojurescript. You could patch quil.applet so it uses same feature to skip calling runSketch. Feel free to send pull request! 

Thanks,
Nikita

Alex Fowler

unread,
Oct 13, 2015, 10:08:00 AM10/13/15
to clj-processing, alex.m...@gmail.com
Got some more experience with that (both clj and cljs). Gotta make a PR soon.

воскресенье, 26 июля 2015 г., 22:08:37 UTC+4 пользователь Nikita Beloglazov написал:

Alex Fowler

unread,
Oct 13, 2015, 10:56:43 AM10/13/15
to clj-processing, alex.m...@gmail.com
Actually, in my real solution I simply went with multiple PGraphics objects. I did not need to create many processing sketches.

However, the feature may nevertheless be useful.

Now looked at it. I think it should be done like this:

* if the user wants to have several sketches, he calls `quil.applet/applet` with the :no-start parameter and receives a `[prx-obj start-fn]` so that he can store the prx-obj for his needs and call the start-fn when he's ready to init the applet. Also, no def happens for the applet object, the user must take care himself.
* if the user wants the way it it now - he simply uses defsketch as before.

Would that be ok? Or do you think it complicates things?

Nikita Beloglazov

unread,
Oct 14, 2015, 1:54:09 AM10/14/15
to clj-processing, alex.m...@gmail.com
I would suggest using quil.core/sketch instead of quil.applet/applet as quil.applet is a "private" namespace. All functionality users might need for day-to-day usage should be possible by using only quil.core. And then you need to get start-fn function from somewhere. I'd suggest creating a new quil.core/start-sketch or something which takes sketch object and starts it. 

You proposal with applet returning vector of sketch and function is also good, but we already have 2 functions that create sketch (defsketch and sketch) and adding third seems redundant to me.  

Thanks,
Nikita

--
Reply all
Reply to author
Forward
0 new messages