lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I would advise:

Either refactor your C/C++ libraries for more efficient calls, and
then use a wrapper generator such as SWIG, or hand-coded LUA C API

Or use LuaJIT/FFI and do your work in Lua,  but using C structures and
arrays that you declare and allocate from Lua and access from local

I think with the right design either of these approaches would work.
Of course the two approaches can be combined.

If you declare C++ classes as "plain old data" structures, then you
can alias them with C struct declarations in LuaJIT/FFI. Then you can
pass pointers back and forth as lightuserdata and type cast them in
LuaJIT/FFI. In this way, with care, you can use either C++ or Lua to
work on the same data in a very efficient way.


On Thu, Oct 20, 2011 at 9:52 PM, Xavier Wang <> wrote:
> 2011/10/21 Patrick Donnelly <>:
>> On Thu, Oct 20, 2011 at 9:37 PM, Xavier Wang <> wrote:
>>>  - write it in pure Lua? first is the speed, maybe LuaJIT may fast,
>>> then, using Lua to do actually render?
>> Yes! Use LuaJIT 2.x with FFI. I believe plenty of people have already
>> have opengl FFI bindings written. Just google around. With the FFI, it
>> should be lightning fast...
>> --
>> - Patrick Donnelly
> This is a good idea, thank you :-)
> May be I should learn to wrtie C wrappers for C++ class, and try to
> write FFI interface (may be meta-method is supported) for my C++
> libraries.
> Thank you.

Michael Gogins
Irreducible Productions
Michael dot Gogins at gmail dot com