Pages: [1]
Author Topic: ofxLua  (Read 2011 times)
danomatika
robotcowboy industries

Posts: 143

Gravatar


WWW
ofxLua
« on: June 18, 2011, 10:52:58 PM »

Announcing ofxLua, an Open Frameworks addon for running a Lua embedded scripting interpreter within an OpenFrameworks application. Using the luabind library, C++ functions and classes can be bound to the lua api allowing them to be called within a lua script. This is useful in separating the upper level logic from the lower level application and is utilized in numerous video games and applications.

Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, runs by interpreting bytecode for a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping.

Luabind is a library that helps you create bindings between C++ and Lua. It has the ability to expose functions and classes, written in C++, to Lua. It will also supply the functionality to define classes in lua and let them derive from other lua classes or C++ classes. Lua classes can override virtual functions from their C++ baseclasses.

https://github.com/danomatika/ofxLua

The current example is written for OF 007. I will add an iOS example soon.

Included is an example OF api binding (maybe 45%) and 4 OF examples implemented as lua scripts:
« Last Edit: June 20, 2011, 05:23:50 PM by danomatika » Logged

danomatika
robotcowboy industries

Posts: 143

Gravatar


WWW
Re: ofxLua
« Reply #1 on: June 20, 2011, 05:23:06 PM »

Since OF 007 will be out soon, I decided not to change the example for 0062 compatibility. It would be pretty messy and the example scripts would have to be replicated etc. ofxLua itself will build and work fine, only the example projects, OF api wrapper, and scripts will not work.
Logged

Akira Hayasaka
Tokyo Japan

Posts: 54

Gravatar


WWW
Re: ofxLua
« Reply #2 on: July 14, 2011, 07:02:02 AM »

Hello Dan, this oF Lua binding is amazing,
thank you for sharing code! :)

Currently I am developing kind of livecoding environment using ofxLua.

I am trying to overlay transparent png with ofEnableAlphaBlending().
But seems not working.
I attach screen shot.
The eye is transparent png.
It "is" transparent.
but it is only transparent to back ground color.
it is not transparent to the image which i place on the screen,
So I cannot see the mountain image through eye image.
I confirmed that this eye image is truly transparent in the usual oF desktop App.

Do you know why the image is not fully transparent?

Thanks!


* screen.png (377.07 KB, 500x313 - viewed 757 times.)
Logged

bilderbuchi
Global Moderator
Vienna, Austria

Posts: 902

Gravatar


Re: ofxLua
« Reply #3 on: July 14, 2011, 10:33:33 AM »

have you tried drawing the bg before the eye?
Logged
Akira Hayasaka
Tokyo Japan

Posts: 54

Gravatar


WWW
Re: ofxLua
« Reply #4 on: July 15, 2011, 01:41:47 AM »

Thank you for reply bilderbuchi,

Yea I have tried but mountain img covers eye img, so I cannot see eye...
Logged

Akira Hayasaka
Tokyo Japan

Posts: 54

Gravatar


WWW
Re: ofxLua
« Reply #5 on: July 16, 2011, 03:25:10 AM »

transparent png problem still not solved though,

I putted ofxGLEditer here
https://github.com/Akira-Hayasaka/ofxGLEditor

I am using ofxGLEditer for Live Coding with ofxLua.
And this should be able to be used with other script language addons.

Cheers
Logged

Akira Hayasaka
Tokyo Japan

Posts: 54

Gravatar


WWW
Re: ofxLua
« Reply #6 on: July 18, 2011, 01:42:21 AM »

Seems the png transparency problem was caused by img's z value.
glDisable(GL_DEPTH_TEST) or ofTranslate(0,0,1) makes it transparent.

Thanks


* Screen shot 2011-07-18 at 9.37.43.png (380.71 KB, 500x313 - viewed 713 times.)
Logged

danomatika
robotcowboy industries

Posts: 143

Gravatar


WWW
Re: ofxLua
« Reply #7 on: July 22, 2011, 06:39:55 PM »

Great to hear it's working. I'm currently looking into a script to build boost for iOS so ofxLua is usable on my iPad ...
Logged

danomatika
robotcowboy industries

Posts: 143

Gravatar


WWW
Re: ofxLua
« Reply #8 on: July 27, 2011, 04:42:09 PM »

Great to hear it's working. I'm currently looking into a script to build boost for iOS so ofxLua is usable on my iPad ...

Ok, I have ofxLua working in iOS ... I imagine you could port your live coding environment and use a usb keyboard on an iPad!

I will commit the xcode project soon.
Logged

danomatika
robotcowboy industries

Posts: 143

Gravatar


WWW
Re: ofxLua
« Reply #9 on: September 22, 2011, 09:20:25 AM »

I updated all the example project files for xcode 4 and OF 007. Also, the static lib project has been split into mac os and ios versions. This should make things easier.
Logged

danomatika
robotcowboy industries

Posts: 143

Gravatar


WWW
Re: ofxLua
« Reply #10 on: September 14, 2012, 05:44:47 PM »

More updates.

Now you can read and write variables in the lua state and write out values into a lua text file. The main idea is that you can use lua scripts for loading/saving data akin to ofxXmlSettings and uses a similar pushTable/popTable mechanism like xml pushTag/popTag.

Here's a little bit of the read api:

Code:
// print the variables in the script manually
ofLog() << "variableTest variables:";
ofLog() << " abool: " << lua.getBool("abool");
ofLog() << " afloat: " << lua.getFloat("afloat");
ofLog() << " astring: " << lua.getString("astring");

// read manually by index, remember lua indices start at 1 not 0!
lua.pushTable("mixedTable");
ofLog() << "mixedTable";
for(int i = 1; i <= lua.tableSize(); ++i) {
if(lua.isBool(i)) {
ofLogNotice() << i << " b: " << lua.getBool(i);
}
else if(lua.isFloat(i)) {
ofLogNotice() << i << " f: " << lua.getFloat(i);
}
else if(lua.isString(i)) {
ofLogNotice() << i << " s: " << lua.getString(i);
}
}
lua.popTable();

Check out the api test in the example for more.
« Last Edit: September 14, 2012, 05:47:05 PM by danomatika » Logged

Pages: [1]
 
Jump to:  

Powered by SMF 1.1.15 | SMF © 2011, Simple Machines

viagra priser