lua-users home
lua-l archive

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

On 10/20/11 6: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++

Just expose them through a "C" opaque interface. ZeroMQ, AntTweakBar are using C++ internally (and even STL), but expose "C" interface.

I haven't checked recently, but even ZeroMQ C++ "binding" is written b reusing the "C" one.

It's not a bad design choice. C++ can be good for isolated pieces of code, where you can throw exceptions only to things known to you - your library. As soon as you throw up, it gets ugly. Don't throw things to other libs, or the main application that's using you. It's simply bad design for a C++. Just use the damn error codes.

"C" interface for the win. There haven't been anything more successful than it - SDK-s, OS-s, a lot of stuff gets written by exposing "C".

Hopefully in the future we'll have callbacks for luajit, until then it'll still be a puzzle in my head how to do, and still work on more platforms.