Jump to content

[SOLVED] add setAppPath to PluginApi for better flexibility


photo

Recommended Posts

I don't know if I post this in forum is appropriate, but current C++ Plugin API has one or more limitations that can be easily solved.

  1. Current engine only use GetModuleFileName to get application path, but if someone want to use unigine in his own dll and this dll are hosted by another program. like a browser plugin, the GetModuleFileName always returns the full path of firefox.exe or iexplorer.exe, so without the setAppPath function to set application path before engine initialize, the engine will refuse to initialize.
  2. related to above, if one plugin are specified within a subfolder of application path, like "plugins/PluginA", then the EnginePlugins.cpp can not load the plugin, because LoadLibrary can not find the dll file to load, because A, there is no search path for that dll plugin, B, LoadLibrary can not use forward slashes

 

So I've made some modifications to source, added a static function of setAppPath to set the applications path, and use SetDllDirectory to add the applications path to dll search path.

 

Don't know many of linux programming, But I'm sure under linux, the problem still exists.

 

Here are patches based on UnigineSDK-source-2012-06-14.

 

apppath.patch.rar

Link to comment
  • 2 weeks later...

An additional Engine::init() function will be available for engine initialization with arbitrary application path:

/**
* @brief Initialize a new engine with external graphic application.
* @param version Version number (UNIGINE_VERSION).
* @param app Pointer to the graphic App class (NULL to ignore).
* @param path Application path (NULL to ignore).
* @param argc Number of command line arguments.
* @param argv Array of command line arguments values.
* @param project Project name (NULL to ignore); if set, it forces the engine to store all changing data (log file, cache files, config file) in user profile rather than in a directory with binaries.
* @param password Password for the filesystem archives (NULL to ignore).
* @return Pointer to the new engine.
*/
static UNIGINE_API Engine *init(int version,App *app,const char *path,int argc,char **argv,const char *project = 0,const char *password = 0);

Link to comment
×
×
  • Create New...