lua-users home
lua-l archive

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


> 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.

Sorry, I wrote that rather quickly, as I had to run off to a meeting :0)

typedef float Matrix;

// You might put code in tolua wrapper or in game.
$Matrix* matrix_create() { return malloc(sizeof(Matrix)*16); }
$void matrix_set(Matrix* m,int r,int c, float val) {m[r][c]=val;}
$float matrix_get(Matrix* m,int r,int c) {return m[r][c];}

Matrix* matrix_create();
void matrix_set(Matrix* m,int r,int c, float val);
float matrix_get(Matrix* m,int r,int c);

might be a little clearer and error free?

N