How to pass a matrix to lua?

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
unholysavagery
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 73
Joined: Tue Oct 28, 2008 4:27 am

How to pass a matrix to lua?

Post by unholysavagery »

My engine needs control over matrices but if I pass a pointer it will create a new matrix every time I multiply it. So I need to push the actual matrix but I don't know how to push an array on to the stack.

Any ideas? Do I push each element of it?
This is the internet, men are men, women are men and children are the FBI.
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: How to pass a matrix to lua?

Post by Falco Girgis »

Yeah, you're going to have to use some sort of 2-layer loop if you're pushing and popping from the stack. I would recommend doing something like pass by reference, but I'm not good enough at working with raw Lua userdata without going through toLua++ to say anything on the matter.
Post Reply