Changeset 2799 for code/branches/gui/src/orxonox
- Timestamp:
- Mar 18, 2009, 9:15:39 PM (16 years ago)
- Location:
- code/branches/gui/src/orxonox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gui/src/orxonox/Main.cc
r2716 r2799 34 34 35 35 #include "OrxonoxStableHeaders.h" 36 #include "OrxonoxConfig.h" 36 37 37 38 #include <exception> 38 39 #include <cassert> 39 40 40 #include "OrxonoxConfig.h"41 41 #include "util/Debug.h" 42 #include "util/SignalHandler.h" 43 #include "core/ConfigFileManager.h" 44 #include "core/CommandLine.h" 45 #include "core/CommandExecutor.h" 42 #include "core/Core.h" 46 43 #include "core/Identifier.h" 47 #include "core/Core.h"48 #include "core/Language.h"49 44 50 45 #include "gamestates/GSRoot.h" … … 85 80 86 81 87 SetCommandLineArgument(settingsFile, "orxonox.ini");88 SetCommandLineArgument(configFileDirectory, "");89 82 90 83 int main(int argc, char** argv) 91 84 { 92 using namespace orxonox; 93 94 // Parse command line arguments 95 try 85 orxonox::Core* core = new orxonox::Core(argc, argv); 86 if (!core->isLoaded()) 96 87 { 97 CommandLine::parseAll(argc, argv); 88 COUT(0) << "Core was not fully loaded, probably an exception occurred during consruction. Aborting" << std::endl; 89 abort(); 98 90 } 99 catch (ArgumentException& ex)100 {101 COUT(1) << ex.what() << std::endl;102 COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl;103 }104 105 // Do this after parsing the command line to allow customisation106 Core::postMainInitialisation();107 108 // create a signal handler (only active for linux)109 SignalHandler signalHandler;110 signalHandler.doCatch(argv[0], Core::getLogPathString() + "orxonox_crash.log");111 112 // Create the ConfigFileManager before creating the GameStates in order to have113 // setConfigValues() in the constructor (required).114 ConfigFileManager* configFileManager = new ConfigFileManager();115 configFileManager->setFilename(ConfigFileType::Settings, CommandLine::getValue("settingsFile").getString());116 // create the Core settings to configure the output level117 Language* language = new Language();118 Core* core = new Core();119 91 120 92 // put GameStates in its own scope so we can destroy the identifiers at the end of main(). 121 93 { 94 using namespace orxonox; 122 95 // create the gamestates 123 96 GSRoot root; … … 143 116 } 144 117 145 // destroy singletons118 // Destroy pretty much everyhting left 146 119 delete core; 147 delete language;148 delete configFileManager;149 120 150 121 // Clean up class hierarchy stuff (identifiers, xmlport, configvalue, consolecommand) 151 Identifier::destroyAllIdentifiers(); 152 // destroy command line arguments 153 CommandLine::destroyAllArguments(); 154 // Also delete external console command that don't belong to an Identifier 155 CommandExecutor::destroyExternalCommands(); 122 // Needs to be done after 'delete core' because of ~OrxonoxClass 123 orxonox::Identifier::destroyAllIdentifiers(); 156 124 157 125 return 0; -
code/branches/gui/src/orxonox/gamestates/GSGraphics.h
r2756 r2799 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include <OgrePrerequisites.h>34 33 #define NOMINMAX // required to stop windows.h screwing up std::min definition 35 34 #include <OgreWindowEventUtilities.h> 35 #include <OgreLog.h> 36 36 #include "core/GameState.h" 37 37 #include "core/OrxonoxClass.h" -
code/branches/gui/src/orxonox/gamestates/GSRoot.cc
r2759 r2799 33 33 #include "util/Debug.h" 34 34 #include "core/Core.h" 35 #include "core/Factory.h"36 35 #include "core/ConfigValueIncludes.h" 37 36 #include "core/CoreIncludes.h" 38 37 #include "core/ConsoleCommand.h" 39 #include "core/CommandLine.h"40 #include "core/Shell.h"41 #include "core/TclBind.h"42 #include "core/TclThreadManager.h"43 #include "core/LuaBind.h"44 38 #include "tools/Timer.h" 45 39 #include "objects/Tickable.h" 46 40 47 #ifdef ORXONOX_PLATFORM_WINDOWS48 # ifndef WIN32_LEAN_AND_MEAN49 # define WIN32_LEAN_AND_MEAN50 # endif51 # define NOMINMAX // required to stop windows.h screwing up std::min definition52 # include "windows.h"53 #endif54 55 41 namespace orxonox 56 42 { 57 SetCommandLineArgument(limitToCPU, 1).information("0: off | #cpu");58 59 43 GSRoot::GSRoot() 60 44 : RootGameState("root") … … 62 46 , bPaused_(false) 63 47 , timeFactorPauseBackup_(1.0f) 64 , tclBind_(0)65 , tclThreadManager_(0)66 , shell_(0)67 48 { 68 49 RegisterRootObject(GSRoot); … … 87 68 void GSRoot::enter() 88 69 { 89 // creates the class hierarchy for all classes with factories90 Factory::createClassHierarchy();91 92 70 // reset game speed to normal 93 71 timeFactor_ = 1.0f; … … 100 78 this->avgTickTime_ = 0.0f; 101 79 102 // Create the lua interface103 this->luaBind_ = new LuaBind();104 105 // initialise TCL106 this->tclBind_ = new TclBind(Core::getMediaPathString());107 this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter());108 109 // create a shell110 this->shell_ = new Shell();111 112 // limit the main thread to the first core so that QueryPerformanceCounter doesn't jump113 // do this after ogre has initialised. Somehow Ogre changes the settings again (not through114 // the timer though).115 int limitToCPU = CommandLine::getValue("limitToCPU");116 if (limitToCPU > 0)117 setThreadAffinity((unsigned int)(limitToCPU - 1));118 119 80 { 120 81 // add console commands … … 156 117 delete this->ccSelectGameState_; 157 118 158 delete this->shell_;159 delete this->tclThreadManager_;160 delete this->tclBind_;161 162 delete this->luaBind_;163 164 119 if (this->ccSetTimeFactor_) 165 120 { … … 179 134 uint64_t timeBeforeTick = time.getRealMicroseconds(); 180 135 181 TclThreadManager::getInstance().tick(time.getDeltaTime());136 Core::getInstance().tick(time); 182 137 183 138 for (ObjectList<TimerBase>::iterator it = ObjectList<TimerBase>::begin(); it; ++it) … … 235 190 236 191 /** 237 @note238 The code of this function has been copied and adjusted from OGRE, an open source graphics engine.239 (Object-oriented Graphics Rendering Engine)240 For the latest info, see http://www.ogre3d.org/241 242 Copyright (c) 2000-2008 Torus Knot Software Ltd243 244 OGRE is licensed under the LGPL. For more info, see OGRE license.245 */246 void GSRoot::setThreadAffinity(unsigned int limitToCPU)247 {248 #ifdef ORXONOX_PLATFORM_WINDOWS249 // Get the current process core mask250 DWORD procMask;251 DWORD sysMask;252 # if _MSC_VER >= 1400 && defined (_M_X64)253 GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask);254 # else255 GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask);256 # endif257 258 // If procMask is 0, consider there is only one core available259 // (using 0 as procMask will cause an infinite loop below)260 if (procMask == 0)261 procMask = 1;262 263 // if the core specified with limitToCPU is not available, take the lowest one264 if (!(procMask & (1 << limitToCPU)))265 limitToCPU = 0;266 267 // Find the lowest core that this process uses and limitToCPU suggests268 DWORD threadMask = 1;269 while ((threadMask & procMask) == 0 || (threadMask < (1u << limitToCPU)))270 threadMask <<= 1;271 272 // Set affinity to the first core273 SetThreadAffinityMask(GetCurrentThread(), threadMask);274 #endif275 }276 277 /**278 192 @brief 279 193 Changes the speed of Orxonox -
code/branches/gui/src/orxonox/gamestates/GSRoot.h
r2710 r2799 33 33 34 34 #include <list> 35 #include <OgreLog.h>36 35 #include "core/RootGameState.h" 37 36 #include "core/OrxonoxClass.h" … … 76 75 77 76 void setConfigValues(); 78 void setThreadAffinity(unsigned int limitToCPU);79 77 80 78 float timeFactor_; //!< A factor that sets the gamespeed. 1 is normal. 81 79 bool bPaused_; 82 80 float timeFactorPauseBackup_; 83 TclBind* tclBind_;84 TclThreadManager* tclThreadManager_;85 Shell* shell_;86 LuaBind* luaBind_;87 81 88 82 // variables for time statistics -
code/branches/gui/src/orxonox/objects/worldentities/Model.cc
r2662 r2799 31 31 #include <OgreEntity.h> 32 32 #include "Model.h" 33 #include "core/Core.h" 33 34 #include "core/CoreIncludes.h" 34 35 #include "core/XMLPort.h" -
code/branches/gui/src/orxonox/objects/worldentities/ParticleEmitter.cc
r2662 r2799 39 39 #include "tools/ParticleInterface.h" 40 40 #include "util/Exception.h" 41 #include "core/Core.h" 41 42 #include "core/CoreIncludes.h" 42 43 #include "core/XMLPort.h"
Note: See TracChangeset
for help on using the changeset viewer.