?
Plugins.cfg
Ogre的許多功能是以插件的形式提供的.Ogre提供的以Plugin_開頭的許多.DLL文件都是所謂的插件。
Plugins.cfg指定了插件的路徑和插件文件名, 它們可以放在其它文件夾里,但必須在本文件里指定路徑。
在 windows 平臺插件的裝入過程如下:
Root::()
{
?? if(!pluginFileName.empty())
?? loadPlugins(pluginFileName);
}
――――――>
void Root::loadPlugins(const String& pluginsfile)
{
?? ConfigFile cfg;
?? cfg.load(pluginsfile);
??? ...........................
?? // 解析文件,處理后將目錄與文件名聯(lián)接
? for(;;)
?? loadPlugin(plugindir + (*it))
} ――――――>
Root::loadplugin(const string&? pluginName)
{
?? DyLibmanager::getsinleton.load(pluginName);
}
――――――>
DynLibManager::load(const string& filename)
{
??????? DynLib* pLib=new DynLib(filename);
??????? pLib->load();
}
――――――>
void DynLib::load()
{
????? m_hInst=(DYNLIB_HANDLE)DYNLIB_LOAD(name.cstr());
}
在 windows 平臺下有如下定義:
#define? DYNLIB_LOAD(a)???? LoadLibrary(a)
到此, x.dll 插件被加載到內(nèi)存中,可以使用插件的功能了^_^
以下為一個典型的 Plugins.cfg 文件的內(nèi)容:
# Defines plugins to load
# Define plugin folder
PluginFolder=.
# Define plugins
Plugin=RenderSystem_Direct3D9
Plugin=RenderSystem_GL
Plugin=Plugin_ParticleFX
Plugin=Plugin_BSPSceneManager
Plugin=Plugin_OctreeSceneManager
Plugin=Plugin_CgProgramManager
Plugins.cfg 文件內(nèi)容相當(dāng)直觀,不再贅述。
posted on 2007-03-02 17:31
清源游民 閱讀(1230)
評論(0) 編輯 收藏 引用 所屬分類:
OGRE