[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaJIT FFI only bindings for glfw, OpenCL, OpenGL
- From: Richard Hundt <richardhundt@...>
- Date: Wed, 26 Jan 2011 15:42:45 +0100
Hi,
So far I've had only one issue, not being able to do callbacks (as
Mike explained lua -> FFI -> C -> lua).
This probably doesn't solve this problem, but you can do something like
this:
<code>
local ffi = require"ffi"
ffi.cdef(io.open('luadefs.h', "r"):read"*a")
local lua = ffi.load('./src/libluajit.so')
local state = lua.luaL_newstate()
lua.luaL_openlibs(state)
lua.luaL_loadstring(state, [[
print("CHEESE!")
]])
lua.lua_call(state, 0, 0)
</code>
With a little C helper function you could return the current lua_State
without the need to first do luaL_newstate. Now to figure out how to
pass data back and forth :)
Cheers,
Richard