lua-users home
lua-l archive

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

Thanks!  It seems const was the problem.

On Tue, Sep 13, 2011 at 12:52 PM, Mike Pall <> wrote:
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 ="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 ="const GLchar *[1]", str)
 local l ="GLint[1]", #str)
 GLESv2.glShaderSource(shader, 1, s, l)