I am working on a 2D game engine at the moment and have hit a stumbling block whilst implementing the LUA scripting / Interpreter.
I’m using SWIG and have got the basics all working fine.
In the engine I use the GLM (OpenGL Mathematics Libary http://glm.g-truc.net/) for all Vector and Matrix related areas.
I really need to expose glm (at a basic level) to the via SWIG to LUA so I can call methods in LUA like:
actor:GetPosition() <- Which returns a glm::vec2
GLM is quite a complex library (possibly an understatement lol) and I do not require the whole thing exposed, that would be ridiculous amounts of work I assume. I simply want to be able to access the xy components of the glm::vec2 class.
I’m sure this must be easy as SWIG doesn’t require a full class definition and there must be a way to let SWIG just assume that the glm::vec2 class just has x,y params.
I’m not sure If using Proxy classes in SWIG is the way to do this ? or some other method ? I’m quite new to LUA integration and SWIG also.
One route I really don’t want to go down is ditching GLM and writing my own Vector/Matrix library which is much more simple, no templates etc and I can then simply wrap with SWIG, but I feel this would be a waste of time and I would ultimately end up with a less powerful Math Library :(.
Thanks in advance and I can provide more info if necessary.
A solution in luabind would look like this: