-----------------------------------------------------------------------
| 1452 | } |
| 1453 | //----------------------------------------------------------------------- |
| 1454 | void Root::loadPlugin( const String &pluginName, const bool bOptional, |
| 1455 | const NameValuePairList *options ) |
| 1456 | { |
| 1457 | #if OGRE_PLATFORM != OGRE_PLATFORM_EMSCRIPTEN |
| 1458 | // Load plugin library |
| 1459 | DynLib *lib = DynLibManager::getSingleton().load( pluginName, bOptional ); |
| 1460 | |
| 1461 | // Store for later unload |
| 1462 | // Check for existence, because if called 2+ times DynLibManager returns existing entry |
| 1463 | if( std::find( mPluginLibs.begin(), mPluginLibs.end(), lib ) == mPluginLibs.end() ) |
| 1464 | { |
| 1465 | mPluginLibs.push_back( lib ); |
| 1466 | |
| 1467 | if( lib->isLoaded() ) |
| 1468 | { |
| 1469 | // Call startup function |
| 1470 | # ifdef __GNUC__ |
| 1471 | __extension__ |
| 1472 | # endif |
| 1473 | DLL_START_PLUGIN pFunc = (DLL_START_PLUGIN)lib->getSymbol( "dllStartPlugin" ); |
| 1474 | |
| 1475 | if( !pFunc ) |
| 1476 | { |
| 1477 | OGRE_EXCEPT( Exception::ERR_ITEM_NOT_FOUND, |
| 1478 | "Cannot find symbol dllStartPlugin in library " + pluginName, |
| 1479 | "Root::loadPlugin" ); |
| 1480 | } |
| 1481 | |
| 1482 | try |
| 1483 | { |
| 1484 | // This must call installPlugin |
| 1485 | pFunc( options ); |
| 1486 | } |
| 1487 | catch( Exception &e ) |
| 1488 | { |
| 1489 | if( !bOptional ) |
| 1490 | { |
| 1491 | throw; |
| 1492 | } |
| 1493 | else |
| 1494 | { |
| 1495 | LogManager::getSingleton().logMessage( |
| 1496 | "Optional Plugin " + pluginName + " failed with exception:", LML_CRITICAL ); |
| 1497 | LogManager::getSingleton().logMessage( e.getFullDescription(), LML_CRITICAL ); |
| 1498 | } |
| 1499 | } |
| 1500 | } |
| 1501 | } |
| 1502 | #endif |
| 1503 | } |
| 1504 | //----------------------------------------------------------------------- |
| 1505 | void Root::unloadPlugin( const String &pluginName ) |
| 1506 | { |