I'm trying to expose two classes to Lua using LuaBridge. These classes are Sprite
and Texture
that look something like this:
class Texture
{
public:
Texture(const std::string& filename);
...
}
class Sprite
{
public:
Sprite(Texture& texture);
...
}
Now, I try to bind these to Lua like this:
lua_State* L = ...;
luabridge::getGlobalNamespace(L)
.beginClass<Texture>("Texture") // No ctor exposed, just the class
.endClass()
.beginClass<Sprite>("Sprite")
.addConstructor<void(*)(Texture&)>() // This causes the error
.endClass();
However, this produces the following compile error:
C2664: cannot convert argument 1 from 'const Texture' to 'Texture &'
Why do I get this error and how can I fix it?