Can openFrameworks do live coding and how

this is something ive been wondering for some time really, and have found some stuff on this forum, but its pretty old now id say.

now what i mean by live coding is not the sense of seeing text on screen along the top of what im making. but rather i see the openframworks app running in its regular own window then i change something in xcode, i save it and it updates the window. much like bret victors talk some years ago where he had something that constantly updates.
but even if it only updates once saving im happy with that

i just want to see about just stopping the constant cycle of running the app, then realising something is wrong, stop it, go and do the changes then start it again.
is there something like that for openframeworks that works for all systems?

and im not looking to go to something which has openframeworks in, id rather stick with it than move to something like ‘gamuza’, is it called that? it looks good but its just something else. when id prefer to stick using xcode and sublime for editing ofxLua lua files

any tips or ideas would be greatful because it is just a bit annoying soetimes, when you could just have it run for a while and see the changes right away


If you want to change variables “on the fly” in your application - GUI is a good solution
ofxPanel could be helpful, there is a nice example in OF folder

gui is not really what im after, at all. i know of gui, been using it for a while. what i said is code based. window is running, but you can change code in your IDE.
gui is not the answer

Check out ofxGLEditor

I contributed the glslExample that lets you do live coding of glsl frag shaders within the oF window. There is support for Lua already and its pretty easy to support other languages.

aye, ive just come across that. looks nice. plus uses lua, so thats nice. ill give it a good looking at

but is there, or has there been anything, where i can just code in an IDE just save and it updates the window? so if i am just using say c++/oF and not lua, then it would be fine

i know there is something in LÖVE2D, which also is coded in lua. but it runs it in the window constantly, you just update sublime text, save, then it updates on screen. its nice. though admittedly im not using LÖVE2D anymore :wink:

aye ofxGLEditor is nice. though some things are a bit awry with me. whilst i know its all for live coding, as in, improvised - this is not what im personally after.
think its not that im after to do it that way, since it seems like nothing can be saved to file, which is what i need.

with that ‘lurker’ LOVE2D plugin is actually exactly what im after. i can edit in say sublime, save and updates on the window.
ofxGLEditor will probably make its way on to something one day for me. but for really getting down and making something to keep for future use and projects, it doesnt solve that. its good mind

You can press command + e to save the file in the glslExample. look at the code that is triggered when that key command is issued. Lets you save the current text buffer to file and then you can call on another command to reload your shader.

If you are looking for similar functionality with oF then that’s a different story but you can evaluate and save the current code buffer with ofxGLEditor.

I think live coding goes against the C++ model, since it’s a compiled language.
In the end, you’d need to have a programming language build on top of c++ and working in a non-compiled oriented fashion (such as Super Collider for example).
I think the javascript version of processing allows for that, maybe you should try it!

actually. on thinking on this a bit further when food shopping.
couldnt ofxLua, which i am using because i want to use lua, only lua. but couldnt that be used to say ‘update’ things on the lua side while in runtime?
so i guess we could work c++ out of it and just use lua. which is fine in this respect

realistically it could because of ofxGLEditor and its own way to update on runtime. the main difference, rather than having the use the editor on the running window, is that it would be edited on a text editor.

i guess the main question is ‘could this be done?’ im sure it could. just how. im just playing with ofxGLEditor, but doing any updating of the lua file from a text editor is not working. but im sure this could work this way using lua


ill extend this to @danomatika since ofxGLEditor is one of his babies :wink:

Simplest method with an external editor would be to periodically check the timestamp of the script file in the update function. If the timestamp is newer, then reload it automatically. I would’t do this on every update, but use a timer/millis and do it maybe once every 5 seconds or so since opening files is relatively slow when done a lot.

There are also OS specific libraries like inotify which do the same thing.

Totally possible when the C++/C is bound to dynamic languages. ofxLua does just this for Lua. There is also ofxPython and a number of other languages bindings around as well.


To follow up: Looks like Poco (C++ library used inside OF) includes a DirectoryWatcher class. I’ll see if it can provide this functionality.

Yeah, but it’s not C/C++, the live coding goes on in another language. Don’t take me wrong, it’s a great solution and I’d completly forgotten it was possible, but what I sad holds true: live coding goes against the C++ model, since it’s a compiled language.

It’s great to know that those implementations of lua and python exist for oF, and I’m happy to know that they allow for live coding =) Hope you guys get this working, would love to see it!

thats brilliant. would love to see it work. i think it would make a massive difference to many people and the way we would work. true it would be lua based code, but really would be super simple to convert it over.
and since i had played with lurker, which allows load updating in LOVE2D, would be more than sure it could work with at least ofxLua.
its not c++, but its bloody just as good :wink:

I do live coding in C++, based on Casey Muratori’s videos and this old github repo:

I don’t have live-looping working like Casey yet but I think I’m almost there. It’s really just passing around a “savestate” like you would see in an emulator.


sweet balls. thank you for this.
ill give this a look :wink:

let me know if you get stuck, i had to re-write the makefile and do one other thing i forgot. i suppose i should fork it with an updated makefile? i actually don’t know github etiquette.

will do thanks.

i guess as long as you give credit to the original people then i think its ok. guess it would also depend on the licence. though would figure it would be fine since your not asking for money for it etc :wink:

also didnt know about the handmade hero, so will be checking that out :wink:

actually just one error

../libs/openFrameworks/types/ofTypes.h:9:10: fatal error: 'tr1/memory' file not
#include <tr1/memory>
1 error generated.