lua-users home
lua-l archive

Re: luajut ffi help?

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


Tim Caswell wrote:
> I'm trying to use luajit's built-in ffi module to make OpenGL ES 2.0 calls
> using the GLESv2/gl2.h header. I have the header properly parsed and
> everything is working fine, but I can't seem to figure out how to pass in
> strings to functions that accept char*
Lua strings can only be converted to "const char *".
> local string = ffi.new("GLchar*[1]")
> string[0] = str
> GLESv2.glShaderSource(shader, 1, string, #str)
Umm, glShaderSource wants an array of "const GLchar *" and an
array of lengths. I.e. (untested):
 local s = ffi.new("const GLchar *[1]", str)
 local l = ffi.new("GLint[1]", #str)
 GLESv2.glShaderSource(shader, 1, s, l)
--Mike

AltStyle によって変換されたページ (->オリジナル) /