Showing the changes to interface/src/Application.cpp (1 of 2 files). Show all
Unified · Split
| @@ -85,6 +85,8 @@ · 84 unmodified lines | ||
| 85 | 85 | #include "Util.h" |
| 86 | 86 | |
| 87 | 87 | #include "audio/AudioToolBox.h" |
| 88 | +#include "audio/AudioIOStatsRenderer.h" | |
| 89 | +#include "audio/AudioScope.h" | |
| 88 | 90 | |
| 89 | 91 | #include "devices/DdeFaceTracker.h" |
| 90 | 92 | #include "devices/Faceshift.h" |
| @@ -142,8 +144,43 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt · 51 unmodified lines | ||
| 142 | 144 | } |
| 143 | 145 | } |
| 144 | 146 | |
| 147 | +bool setupEssentials(int& argc, char** argv) { | |
| 148 | + unsigned int listenPort = 0; // bind to an ephemeral port by default | |
| 149 | + const char** constArgv = const_cast<const char**>(argv); | |
| 150 | + const char* portStr = getCmdOption(argc, constArgv, "--listenPort"); | |
| 151 | + if (portStr) { | |
| 152 | + listenPort = atoi(portStr); | |
| 153 | + } | |
| 154 | + | |
| 155 | + DependencyManager::registerInheritance<LimitedNodeList, NodeList>(); | |
| 156 | + | |
| 157 | + // Set dependencies | |
| 158 | + DependencyManager::get<GLCanvas>(); | |
| 159 | + auto glCanvas = DependencyManager::set<GLCanvas>(); | |
| 160 | + auto addressManager = DependencyManager::set<AddressManager>(); | |
| 161 | + auto nodeList = DependencyManager::set<NodeList>(NodeType::Agent, listenPort); | |
| 162 | + auto geometryCache = DependencyManager::set<GeometryCache>(); | |
| 163 | + auto glowEffect = DependencyManager::set<GlowEffect>(); | |
| 164 | + auto faceshift = DependencyManager::set<Faceshift>(); | |
| 165 | + auto audio = DependencyManager::set<Audio>(); | |
| 166 | + auto audioScope = DependencyManager::set<AudioScope>(); | |
| 167 | + auto audioIOStatsRenderer = DependencyManager::set<AudioIOStatsRenderer>(); | |
| 168 | + auto deferredLightingEffect = DependencyManager::set<DeferredLightingEffect>(); | |
| 169 | + auto ambientOcclusionEffect = DependencyManager::set<AmbientOcclusionEffect>(); | |
| 170 | + auto textureCache = DependencyManager::set<TextureCache>(); | |
| 171 | + auto animationCache = DependencyManager::set<AnimationCache>(); | |
| 172 | + auto visage = DependencyManager::set<Visage>(); | |
| 173 | + auto ddeFaceTracker = DependencyManager::set<DdeFaceTracker>(); | |
| 174 | + auto modelBlender = DependencyManager::set<ModelBlender>(); | |
| 175 | + auto audioToolBox = DependencyManager::set<AudioToolBox>(); | |
| 176 | + | |
| 177 | + return true; | |
| 178 | +} | |
| 179 | + | |
| 180 | + | |
| 145 | 181 | Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : |
| 146 | 182 | QApplication(argc, argv), |
| 183 | + _dependencyManagerIsSetup(setupEssentials(argc, argv)), | |
| 147 | 184 | _window(new MainWindow(desktop())), |
| 148 | 185 | _toolWindow(NULL), |
| 149 | 186 | _nodeThread(new QThread(this)), |
| @@ -189,7 +226,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 39 unmodified lines | ||
| 189 | 226 | _isVSyncOn(true), |
| 190 | 227 | _aboutToQuit(false) |
| 191 | 228 | { |
| 192 | − auto glCanvas = DependencyManager::set<GLCanvas>(); | |
| 229 | + auto glCanvas = DependencyManager::get<GLCanvas>(); | |
| 230 | + auto nodeList = DependencyManager::get<NodeList>(); | |
| 193 | 231 | Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us |
| 194 | 232 | |
| 195 | 233 | |
| @@ -223,23 +261,14 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 27 unmodified lines | ||
| 223 | 261 | _window->setMenuBar(Menu::getInstance()); |
| 224 | 262 | |
| 225 | 263 | _runningScriptsWidget = new RunningScriptsWidget(_window); |
| 226 | − | |
| 227 | − unsigned int listenPort = 0; // bind to an ephemeral port by default | |
| 228 | − const char** constArgv = const_cast<const char**>(argv); | |
| 229 | − const char* portStr = getCmdOption(argc, constArgv, "--listenPort"); | |
| 230 | − if (portStr) { | |
| 231 | − listenPort = atoi(portStr); | |
| 232 | − } | |
| 233 | 264 | |
| 234 | 265 | // start the nodeThread so its event loop is running |
| 235 | 266 | _nodeThread->start(); |
| 236 | 267 | |
| 237 | 268 | // make sure the node thread is given highest priority |
| 238 | 269 | _nodeThread->setPriority(QThread::TimeCriticalPriority); |
| 239 | − | |
| 240 | − // put the NodeList and datagram processing on the node thread | |
| 241 | − auto nodeList = DependencyManager::set<NodeList>(NodeType::Agent, listenPort); | |
| 242 | 270 | |
| 271 | + // put the NodeList and datagram processing on the node thread | |
| 243 | 272 | nodeList->moveToThread(_nodeThread); |
| 244 | 273 | _datagramProcessor.moveToThread(_nodeThread); |
| 245 | 274 | |
| @@ -460,6 +489,8 @@ Application::~Application() { · 214 unmodified lines | ||
| 460 | 489 | Menu::getInstance()->deleteLater(); |
| 461 | 490 | |
| 462 | 491 | _myAvatar = NULL; |
| 492 | + | |
| 493 | + DependencyManager::destroy<GLCanvas>(); | |
| 463 | 494 | } |
| 464 | 495 | |
| 465 | 496 | void Application::saveSettings() { |