[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: luajut ffi help?
- From: Tim Caswell <tim@...>
- Date: Tue, 13 Sep 2011 13:20:21 -0700
Thanks! It seems const was the problem.
On Tue, Sep 13, 2011 at 12:52 PM, Mike Pall <email@example.com>
Tim Caswell wrote:Lua strings can only be converted to "const char *".
> 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*
Umm, glShaderSource wants an array of "const GLchar *" and an
> local string = ffi.new("GLchar*")
> string = str
> GLESv2.glShaderSource(shader, 1, string, #str)
array of lengths. I.e. (untested):
local s = ffi.new("const GLchar *", str)
local l = ffi.new("GLint", #str)
GLESv2.glShaderSource(shader, 1, s, l)