Jump to content
  • Advertisement
Sign in to follow this  
kaveldun

Registering glm::vec3, compilation error

This topic is 1730 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

 

Share this post


Link to post
Share on other sites
Advertisement

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!