[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Passing multidimensional arrays using tolua
- From: Nick Trout <Nick.Trout@...>
- Date: Wed, 20 Feb 2002 16:23:04 -0000
> We're using tolua to make our 3d engine scriptable. All is ok, but
> now we have this problem: tolua doesn't generate a correct C source
> if in the input .H file there's a declaration of multidimensional
> array!
>
> Example: we have in our cleaned header file
>
> float Vertex[4][4];
>
> The generated .C cannot be compiled because tolua thinks the second
> dimension is the value (or something like that).
>
> And VC++ stops with "Cannot convert from 'float' to 'float[4]'"
>
> What can we do?
You sometimes have to change things for toLua.
float Matrix[16]; // [row*4 + col]
may work better. Or you could add an interface wrapper, toLua pkg:
typedef float Vertex;
$Vertex* vertex_create() { return malloc(Vertex*16); }
$void vertex_set(Vertex* v,int r,int c) {v[r][c]=v;}
$void vertex_get(Vertex* v,int r,int c) {return v[r][c];}
Vertex* vertex_create();
void vertex_set(Vertex* v,int r,int c);
void vertex_get(Vertex* v,int r,int c);
Just a quick example... hope you get the idea.
Regards,
Nick