Changeset 731
- Timestamp:
- 06/07/09 15:20:42 (15 months ago)
- Location:
- trunk/lugre
- Files:
-
- 4 modified
-
include/lugre_ogrewrapper.h (modified) (2 diffs)
-
lua/lib.gui.test.lua (modified) (1 diff)
-
src/lugre_ogrewrapper.cpp (modified) (3 diffs)
-
src/lugre_scripting.ogre.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lugre/include/lugre_ogrewrapper.h
r374 r731 68 68 69 69 // stores some render stats 70 std::string msWindowTitle; 70 71 float mfLastFPS; 71 72 float mfAvgFPS; … … 95 96 Ogre::SceneManager* GetSceneManager (const char* szSceneMgrName="main"); 96 97 98 // config 99 std::vector<std::string> ListRenderSystems (); 100 void SetRenderSystemByName (std::string sRenderSysName); 101 std::vector<std::string> ListConfigOptionNames (std::string sRenderSysName); 102 std::vector<std::string> ListPossibleValuesForConfigOption (std::string sRenderSysName,std::string sConfigOptionName); 103 void SetConfigOption (std::string sName,std::string sValue); 104 std::string GetConfigOption (std::string sName); 105 97 106 /// returns true on success 98 bool Init (const char* szWindowTitle,const char* szOgrePluginDir,const char* szOgreBaseDir); 107 bool Init (const char* szWindowTitle,const char* szOgrePluginDir,const char* szOgreBaseDir,bool bAutoCreateWindow=true); 108 bool CreateWindow (bool bConfigRestoreOrDialog=true); 99 109 void RenderOneFrame (); 100 110 void DeInit (); -
trunk/lugre/lua/lib.gui.test.lua
r727 r731 14 14 15 15 --~ TestChatTabs() 16 TestIrisChatLine()17 --~TestConfigDialog()16 --~ TestIrisChatLine() 17 TestConfigDialog() 18 18 --~ TestMapDialog() 19 19 --~ UOBookTest() -
trunk/lugre/src/lugre_ogrewrapper.cpp
r727 r731 316 316 317 317 /// only call this once at startup 318 bool cOgreWrapper::Init (const char* szWindowTitle,const char* szOgrePluginDir,const char* szOgreBaseDir) {PROFILE 318 bool cOgreWrapper::Init (const char* szWindowTitle,const char* szOgrePluginDir,const char* szOgreBaseDir,bool bAutoCreateWindow) { PROFILE 319 msWindowTitle = szWindowTitle; 319 320 static bool bInitialised = false; 320 321 if (bInitialised) return false; … … 379 380 #endif 380 381 382 if (!bAutoCreateWindow) return true; 383 return CreateWindow(); 384 } 385 386 /* 387 388 ConfigOption 389 String name 390 String currentValue 391 StringVector possibleValues 392 bool immutable 393 394 395 void Ogre::Root::setRenderSystem ( RenderSystem * system ) 396 397 */ 398 399 std::vector<std::string> cOgreWrapper::ListRenderSystems () { 400 std::vector<std::string> res; 401 if (mRoot) { 402 Ogre::RenderSystemList* l = mRoot->getAvailableRenderers(); 403 if (l) for (int i=0;i<l->size();++i) { 404 Ogre::RenderSystem* rs = (*l)[i]; 405 if (rs) res.push_back(rs->getName()); 406 } 407 } 408 return res; 409 } 410 411 void cOgreWrapper::SetRenderSystemByName (std::string sRenderSysName) { 412 if (mRoot) { 413 Ogre::RenderSystem* rs = mRoot->getRenderSystemByName(sRenderSysName); 414 if (rs) mRoot->setRenderSystem(rs); 415 } 416 } 417 418 std::vector<std::string> cOgreWrapper::ListConfigOptionNames (std::string sRenderSysName) { 419 std::vector<std::string> res; 420 if (mRoot) { 421 Ogre::RenderSystem* rs = (sRenderSysName == "") ? mRoot->getRenderSystem() : mRoot->getRenderSystemByName(sRenderSysName); 422 if (rs) { 423 Ogre::ConfigOptionMap& o = rs->getConfigOptions(); // std::map< String, ConfigOption > 424 for (Ogre::ConfigOptionMap::iterator itor=o.begin();itor!=o.end();++itor) res.push_back((*itor).first); 425 } 426 } 427 return res; 428 } 429 430 std::vector<std::string> cOgreWrapper::ListPossibleValuesForConfigOption (std::string sRenderSysName,std::string sConfigOptionName) { 431 std::vector<std::string> res; 432 if (mRoot) { 433 Ogre::RenderSystem* rs = (sRenderSysName == "") ? mRoot->getRenderSystem() : mRoot->getRenderSystemByName(sRenderSysName); 434 if (rs && rs->getConfigOptions().count(sConfigOptionName) > 0) { 435 Ogre::ConfigOption& o = rs->getConfigOptions()[sConfigOptionName]; // StringVector possibleValues 436 for (int i=0;i<o.possibleValues.size();++i) res.push_back(o.possibleValues[i]); 437 } 438 } 439 return res; 440 } 441 442 void cOgreWrapper::SetConfigOption (std::string sName,std::string sValue) { 443 if (mRoot) { 444 Ogre::RenderSystem* rs = mRoot->getRenderSystem(); 445 if (rs) rs->setConfigOption(sName,sValue); 446 } 447 } 448 449 std::string cOgreWrapper::GetConfigOption (std::string sName) { 450 if (mRoot) { 451 Ogre::RenderSystem* rs = mRoot->getRenderSystem(); 452 if (rs) return rs->getConfigOptions()[sName].currentValue; 453 } 454 return ""; 455 } 456 457 458 459 bool cOgreWrapper::CreateWindow (bool bConfigRestoreOrDialog) { 381 460 bool bWinDebug = false; 382 461 //bool carryOn = configure(); 383 462 //if (!carryOn) return false; 384 if ( !mRoot->restoreConfig() && !mRoot->showConfigDialog()) return false;463 if (bConfigRestoreOrDialog && !mRoot->restoreConfig() && !mRoot->showConfigDialog()) return false; 385 464 //mRoot->getRenderSystem()->setConfigOption("RTT Preferred Mode","Copy"); // todo : set via lua ? 386 465 if (bWinDebug) printf("windebug safepoint -2\n"); … … 391 470 //if (!mRoot->showConfigDialog()) return false; 392 471 393 mWindow = mRoot->initialise(true, szWindowTitle);472 mWindow = mRoot->initialise(true,msWindowTitle.c_str()); 394 473 if (bWinDebug) printf("windebug safepoint -1\n"); 395 474 -
trunk/lugre/src/lugre_scripting.ogre.cpp
r727 r731 278 278 279 279 280 /// bool OgreCreateWindow (bConfigRestoreOrDialog) 281 /// only call this once at startup 282 static int l_OgreCreateWindow (lua_State *L) { PROFILE 283 bool bConfigRestoreOrDialog = (lua_gettop(L) >= 1 && !lua_isnil(L,1)) ? (lua_isboolean(L,1) ? lua_toboolean(L,1) : luaL_checkint(L,1)) : true; 284 try { 285 bool res = cOgreWrapper::GetSingleton().CreateWindow(bConfigRestoreOrDialog); 286 lua_pushboolean(L,res); 287 return 1; 288 } catch( Ogre::Exception& e ) { 289 printf("warning, OgreWrapper::CreateWindow failed with exception\n"); 290 PrintOgreExceptionAndTipps(e); 291 } 292 return 0; 293 } 294 280 295 281 296 /// only call this once at startup … … 284 299 std::string sOgrePluginPath = (lua_gettop(L) >= 2 && !lua_isnil(L,2)) ? luaL_checkstring(L,2) : "/usr/local/lib/OGRE"; 285 300 std::string sOgreBaseDir = (lua_gettop(L) >= 3 && !lua_isnil(L,3)) ? luaL_checkstring(L,3) : "./"; 301 bool bAutoCreateWindow = (lua_gettop(L) >= 4 && !lua_isnil(L,4)) ? (lua_isboolean(L,4) ? lua_toboolean(L,4) : luaL_checkint(L,4)) : true; 286 302 287 303 try { 288 bool res = cOgreWrapper::GetSingleton().Init(sWindowTitle.c_str(),sOgrePluginPath.c_str(),sOgreBaseDir.c_str() );304 bool res = cOgreWrapper::GetSingleton().Init(sWindowTitle.c_str(),sOgrePluginPath.c_str(),sOgreBaseDir.c_str(),bAutoCreateWindow); 289 305 lua_pushboolean(L,res); 290 306 return 1; … … 295 311 return 0; 296 312 } 313 314 int MyLuaReturnStringList (lua_State *L,std::vector<std::string> l) { 315 if (!lua_checkstack(L,l.size())) return 0; 316 for (int i=0;i<l.size();++i) lua_pushstring(L,l[i].c_str()); 317 return l.size(); 318 } 319 320 /// slist Ogre_ListRenderSystems () 321 static int l_Ogre_ListRenderSystems (lua_State *L) { PROFILE return MyLuaReturnStringList(L,cOgreWrapper::GetSingleton().ListRenderSystems()); } 322 323 /// void Ogre_SetRenderSystemByName (sRenderSysName) 324 static int l_Ogre_SetRenderSystemByName (lua_State *L) { PROFILE 325 std::string sRenderSysName = luaL_checkstring(L,1); 326 cOgreWrapper::GetSingleton().SetRenderSystemByName(sRenderSysName); 327 return 0; 328 } 329 330 /// void Ogre_SetConfigOption (sName,sValue) 331 static int l_Ogre_SetConfigOption (lua_State *L) { PROFILE 332 std::string sName = luaL_checkstring(L,1); 333 std::string sValue = luaL_checkstring(L,2); 334 cOgreWrapper::GetSingleton().SetConfigOption(sName,sValue); 335 return 0; 336 } 337 /// sValue Ogre_GetConfigOption (sName) 338 static int l_Ogre_GetConfigOption (lua_State *L) { PROFILE 339 std::string sName = luaL_checkstring(L,1); 340 lua_pushstring(L,cOgreWrapper::GetSingleton().GetConfigOption(sName).c_str()); 341 return 1; 342 } 343 344 /// slist Ogre_ListConfigOptionNames (sRenderSysName) 345 static int l_Ogre_ListConfigOptionNames (lua_State *L) { PROFILE 346 std::string sRenderSysName = luaL_checkstring(L,1); 347 return MyLuaReturnStringList(L,cOgreWrapper::GetSingleton().ListConfigOptionNames(sRenderSysName)); 348 } 349 350 /// slist Ogre_ListPossibleValuesForConfigOption (sRenderSysName,sConfigOptionName) 351 static int l_Ogre_ListPossibleValuesForConfigOption (lua_State *L) { PROFILE 352 std::string sRenderSysName = luaL_checkstring(L,1); 353 std::string sConfigOptionName = luaL_checkstring(L,2); 354 return MyLuaReturnStringList(L,cOgreWrapper::GetSingleton().ListPossibleValuesForConfigOption(sRenderSysName,sConfigOptionName)); 355 } 356 297 357 298 358 /// for lua : ang,x,y,z QuaternionToAngleAxis (qw,qx,qy,qz) … … 1635 1695 lua_register(L,"MouseHide", l_MouseHide); 1636 1696 lua_register(L,"InitOgre", l_InitOgre); 1697 1698 lua_register(L,"Ogre_ListRenderSystems", l_Ogre_ListRenderSystems); 1699 lua_register(L,"Ogre_SetRenderSystemByName", l_Ogre_SetRenderSystemByName); 1700 lua_register(L,"Ogre_SetConfigOption", l_Ogre_SetConfigOption); 1701 lua_register(L,"Ogre_GetConfigOption", l_Ogre_GetConfigOption); 1702 lua_register(L,"Ogre_ListConfigOptionNames", l_Ogre_ListConfigOptionNames); 1703 lua_register(L,"Ogre_ListPossibleValuesForConfigOption", l_Ogre_ListPossibleValuesForConfigOption); 1704 1705 lua_register(L,"OgreCreateWindow", l_OgreCreateWindow); 1637 1706 lua_register(L,"ExportOgreFont", l_ExportOgreFont); 1638 1707 lua_register(L,"CloneMesh", l_CloneMesh);
