🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

extending engine with dlls

Started by
1 comment, last by Rain Dog 18 years, 1 month ago
i'm currently thinking about the possibility of extend the engine with some "plugins" dll, which could register new functions and publish new objects to the main program. mainly i have a the main executable, i would like to compile a dll that gets loaded by that, and gets the current asIScriptEngine pointer to register new functions... since i don't know much how to do it i would like to know if someone have already done this and could point me to the right direction, maybe with some simple starting source code if possible. thanx in advance
Advertisement
The way I've done it in the past is to provide an api that is bidirectional.

Ie they implement an interface and your app implements an interface. They then put their dll in your plugins folder and you can load it at run time.

After obtaining a pointer to that interface and passing the plugin a pointer to your interface you can talk back and forth, and hopefully do something useful:)

Cheers
Chris
CheersChris
I link my DLL's w/ the angelscript.h header file.

I export a simple function "RegisterPlugin" that takes an asIScriptEngine* and then register the API like you would any other way.

The DLL is only dependant upon the angelscript.h interface declarations and works out fairly well.

The problems you have to watch for are mostly memory management related, and for example, require you to use the same comiler/settings in some cases like for std::string registration. If your dll function takes a std::string from AS, it had best be the same std::string that it knows about otherwise you will crash.

This topic is closed to new replies.

Advertisement