1
\$\begingroup\$

I am attempting to expose glm vector functions/data to luabridge like so:

    .beginClass<glm::mediump_vec3>("vec3")
    .addConstructor<void(*)(const float&, const float&, const float&)>()
    .addData("x", &glm::mediump_vec3::x)
    .addData("y", &glm::mediump_vec3::y)
    .addData("z", &glm::mediump_vec3::z)
    .addData("r", &glm::mediump_vec3::r)
    .addData("g", &glm::mediump_vec3::g)
    .addData("b", &glm::mediump_vec3::b)
    .endClass();

but I am struggling with the operators, such as addition, as they do not seem to be directly attached to the class, and are in a mess of templates. I'm wondering if I should put in a layer of indirection, and have some kind of simpler, non template version of the vec3 in order to make exposure of methods simpler, or if there is a way to register the operators cleanly. Does anyone know how to do this?

\$\endgroup\$
  • \$\begingroup\$ Hi Ian, did you end up solving this problem? I'm considering something similar at the moment and I'd be interested to see your solution \$\endgroup\$ – Figwig Jan 30 at 10:37
  • \$\begingroup\$ @Figwig I ended up having to write my own non-template vector and matrix classes. The issue is two fold: lua is a C library, which does not support templates, and the operators are again, templated. Writing my own float based versions allowed easy mapping. It's not a quick and easy solution, but it does work. \$\endgroup\$ – Ian Young Feb 2 at 9:11
  • \$\begingroup\$ Thank you for your answer - I'll look at doing something similar! \$\endgroup\$ – Figwig Feb 2 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.