Advertisement

Registering glm::vec3, compilation error

Started by October 24, 2013 04:09 PM
1 comment, last by kaveldun 11 years, 1 month ago

Hello!

I am trying to register a vector class from the glm maths library. I am using the following line when I register the method which returns the x component of the vector:


r = engine->RegisterObjectMethod("Vec3", "float x()", asMETHOD(glm::vec3, x), asCALL_THISCALL); assert(r >= 0);

This however gives me a compilation error saying:



error: C-style cast from 'value_type glm::detail::tvec3<float>::*' to 'void (vec3::*)()' is not allowed

    r = engine->RegisterObjectMethod("Vec3", "float x()", asMETHOD(glm::vec3, x), asCALL_THISCALL); assert(r >= 0);
                                                          ^~~~~~~~~~~~~~~~~~~~~~

 expanded from macro 'asMETHOD'
#define asMETHOD(c,m) asSMethodPtr<sizeof(void (c::*)())>::Convert((void (c::*)())(&c::m))

I am aware that this might be due to glm and not angelscript but I am just wondering if someone has any idea on how this could be solved.

Thanks! smile.png

It looks like GLM only defines swizzles for combinations of dimensions, so access to x, y, and z is done only as members, meaning you're casting a float* into a function pointer. You'll either need to create a global function and register it as a method to AS, or register x, y, and z as properties of the class.

Advertisement

Aah, of course!

I totally overlooked that they are not functions indeed. Thanks a lot :)

This topic is closed to new replies.

Advertisement