Advertisement Jump to content
Sign in to follow this  

wrapping an array of floats, and generic interface?

This topic is 3877 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

1) In my engine I define a vector as:
typedef float vec_t;
typedef vec_t vec3_t[3];

They are always stack- or globally-allocated, never from the heap. What's the optimal way to bind this to AngelScript? 2) In asIScriptGeneric, what's the difference between GetArgAddress, GetArgObject, and GetArgPointer? I'm using the library from C, so there's only pointers (which are only allocated in C code), will there be any effective difference?

Share this post

Link to post
Share on other sites
You can register it with:

float &f(unsigned int i, vec_t &v)
if( i > 2 )
asGetActiveContext()->SetException("Out of bounds");

return v;

engine->RegisterObjectType("vec_t", sizeof(vec_t), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS);
engine->RegisterObjectBehaviour("vec_t", asBEHAVE_INDEX, "float &f(uint)", asFUNCTION(vec_index), asCALL_CDECL_OBJLAST);

GetArgAddress should be used when accessing a reference or handle argument.

GetArgObject should be used when accessing an object argument.

GetArgPointer returns the address of the argument, so that it can be read. This method will be renamed in a future version to something like GetAddressOfArg.

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!