Home           About           Downloads





QtLuaImagine


This project demonstrates the use of scripting languages in a Qt project to enable a 3D "live coding" environment. The scripting languages supported are Lua and Scheme (through s7 Scheme). For a version which uses Common Lisp (through ECL), see QtImagine and QtCSG.

The system calls the functions "update" and "render" in both languages to update and render the frame respectively. These functions can be redefined at runtime at the REPL.

When QtLuaImagine first starts, press "Enter" or click the "Execute" button to load an example Lua source file containing example definitions of update() and render(). Then, load the source file into your favourite text editor, make some changes, then load your freshly edited source file from the REPL by issuing the appropriate load command (dofile("filename.lua") for Lua, or (load "filename.scm") for Scheme) to see the effect of your change instantly. Of course, you can also enter expressions and definitions at the REPL itself. The REPL features a command history.

To build QtLuaImagine from source, you will need:
The Visual Studio .vcproj file is generated from the Qt .pro file, and it uses relative paths in the "Additional Include Directories" and "Additional Dependencies" settings to find Qt headers and libs. Because of this, you will most likely need to regenerate the .vcproj before you load the .sln and start compiling. To do this, open a console, run vsvars32.bat (to set up Visual Studio environment variables), add the Qt bin directory to your path, then issue the command "qmake -tp vc". This will generate a new .vcproj for your setup, and you will then be ready to load the .sln and start compiling.

I have included a default .user file only for your convenience, because it contains an "Environment" setting so that Qt is added to the PATH environment variable when you run or debug. It assumes Qt is in C:\Qt\4.6.3\bin, so change this if it isn't.

A note on compiling for linux: Unlike the earlier Qt projects, this project does not have a separate static library. It is completely described by the .pro file, so compiling this on linux should be as simple as running qmake then make. Even the s7 and lua sources are included, so all that is needed to compile this on your end is Qt.

To see what other functions have been exposed to the REPL, and to see how to add your own, see luainterface.cpp/.h, and schemeinterface.cpp/.h for Lua and Scheme respectively.

I hope this code provides a running start for programmers getting into live coding for the first time.

0 comments:

Post a Comment

If you are commenting to request download links, please include an email address in your comment to receive the download links via email. Comments with email addresses in them will not appear in the comments section.