Jump to content
  • Advertisement
Sign in to follow this  
niteice

wrapping an array of floats, and generic interface?

This topic is 3717 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
Advertisement
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 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!