Jump to content
  • Advertisement
Sign in to follow this  
BornToCode

Registering an void* pointer

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

Is it possible to actually register an function with angelscript that takes a void*. What i am trying to do is be able to do something like this in AngelScript. Sprite bird; Image image; RegisterGlobalObjects(bird); RegisterGlobalObjects(image); So basically what i want to do is be able to pass any objects to the function regardless of his type. and on the C++ side i can take care of it, by typecasting it to the right thing. Is that possible.

Share this post


Link to post
Share on other sites
Advertisement
Since you spoke of a void pointer, do you mean that your c++ function looks like this:


RegisterGlobalObjects(void*);



Because if it does, you cannot cast it to the "right" class, because the "right" class can be anything. Even dynamic_casts won't work here (if you use polymorphism).

Share this post


Link to post
Share on other sites
Dude i know that it can be anything.All i want to know is if it is possible to pass an Object in Anglescript that way, where the object type does not matter.

Let me give a better example. Imagine i am doing this.

In one file i have this.

Map map;
RegisterGlobalObject("GameMap",&map);

Then in another file i want to be able to do this.
Map@ map = (Map@)GetGlobalObject("GameMap");

i just want to know if that is possible to do in Angelscript.

Share this post


Link to post
Share on other sites
You can register void* as your own type. You won't be able to cast within angelscript (but you probably knew that) but you will be able to store the void*, and pass it around and such.

Share this post


Link to post
Share on other sites
You can use the any type that you'll find in the add_on folder. This is a complex container type that can hold any type.

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!