Showing the changes to interface/src/Application.cpp (1 of 104 files). Show all
Unified · Split
| @@ -54,9 +54,12 @@ · 53 unmodified lines | |||
| 54 | 54 | ||
| 55 | #include <AddressManager.h> | 55 | #include <AddressManager.h> |
| 56 | #include <AccountManager.h> | 56 | #include <AccountManager.h> |
| 57 | #include <AmbientOcclusionEffect.h> | ||
| 57 | #include <AudioInjector.h> | 58 | #include <AudioInjector.h> |
| 59 | #include <DeferredLightingEffect.h> | ||
| 58 | #include <DependencyManager.h> | 60 | #include <DependencyManager.h> |
| 59 | #include <EntityScriptingInterface.h> | 61 | #include <EntityScriptingInterface.h> |
| 62 | #include <GlowEffect.h> | ||
| 60 | #include <HFActionEvent.h> | 63 | #include <HFActionEvent.h> |
| 61 | #include <HFBackEvent.h> | 64 | #include <HFBackEvent.h> |
| 62 | #include <LocalVoxelsList.h> | 65 | #include <LocalVoxelsList.h> |
| @@ -65,8 +68,10 @@ · 2 unmodified lines | |||
| 65 | #include <OctalCode.h> | 68 | #include <OctalCode.h> |
| 66 | #include <OctreeSceneStats.h> | 69 | #include <OctreeSceneStats.h> |
| 67 | #include <PacketHeaders.h> | 70 | #include <PacketHeaders.h> |
| 71 | #include <PathUtils.h> | ||
| 68 | #include <PerfStat.h> | 72 | #include <PerfStat.h> |
| 69 | #include <PhysicsEngine.h> | 73 | #include <PhysicsEngine.h> |
| 74 | #include <ProgramObject.h> | ||
| 70 | #include <ResourceCache.h> | 75 | #include <ResourceCache.h> |
| 71 | #include <SoundCache.h> | 76 | #include <SoundCache.h> |
| 72 | #include <UserActivityLogger.h> | 77 | #include <UserActivityLogger.h> |
| @@ -86,10 +91,10 @@ · 13 unmodified lines | |||
| 86 | #include "devices/TV3DManager.h" | 91 | #include "devices/TV3DManager.h" |
| 87 | #include "devices/Visage.h" | 92 | #include "devices/Visage.h" |
| 88 | 93 | ||
| 89 | #include "renderer/ProgramObject.h" | ||
| 90 | #include "gpu/Batch.h" | 94 | #include "gpu/Batch.h" |
| 91 | #include "gpu/GLBackend.h" | 95 | #include "gpu/GLBackend.h" |
| 92 | 96 | ||
| 97 | |||
| 93 | #include "scripting/AccountScriptingInterface.h" | 98 | #include "scripting/AccountScriptingInterface.h" |
| 94 | #include "scripting/AudioDeviceScriptingInterface.h" | 99 | #include "scripting/AudioDeviceScriptingInterface.h" |
| 95 | #include "scripting/ClipboardScriptingInterface.h" | 100 | #include "scripting/ClipboardScriptingInterface.h" |
| @@ -108,6 +113,7 @@ · 12 unmodified lines | |||
| 108 | #include "ui/TextRenderer.h" | 113 | #include "ui/TextRenderer.h" |
| 109 | 114 | ||
| 110 | 115 | ||
| 116 | |||
| 111 | using namespace std; | 117 | using namespace std; |
| 112 | 118 | ||
| 113 | // Starfield information | 119 | // Starfield information |
| @@ -134,15 +140,6 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt · 20 unmodified lines | |||
| 134 | } | 140 | } |
| 135 | } | 141 | } |
| 136 | 142 | ||
| 137 | QString& Application::resourcesPath() { | ||
| 138 | #ifdef Q_OS_MAC | ||
| 139 | static QString staticResourcePath = QCoreApplication::applicationDirPath() + "/../Resources/"; | ||
| 140 | #else | ||
| 141 | static QString staticResourcePath = QCoreApplication::applicationDirPath() + "/resources/"; | ||
| 142 | #endif | ||
| 143 | return staticResourcePath; | ||
| 144 | } | ||
| 145 | |||
| 146 | Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : | 143 | Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : |
| 147 | QApplication(argc, argv), | 144 | QApplication(argc, argv), |
| 148 | _window(new MainWindow(desktop())), | 145 | _window(new MainWindow(desktop())), |
| @@ -198,8 +195,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 49 unmodified lines | |||
| 198 | _isVSyncOn(true), | 195 | _isVSyncOn(true), |
| 199 | _aboutToQuit(false) | 196 | _aboutToQuit(false) |
| 200 | { | 197 | { |
| 198 | Model::setViewStateInterface(this); // The model class will sometimes need to know view state details from us | ||
| 199 | |||
| 201 | // read the ApplicationInfo.ini file for Name/Version/Domain information | 200 | // read the ApplicationInfo.ini file for Name/Version/Domain information |
| 202 | QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); | 201 | QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); |
| 203 | 202 | ||
| 204 | // set the associated application properties | 203 | // set the associated application properties |
| 205 | applicationInfo.beginGroup("INFO"); | 204 | applicationInfo.beginGroup("INFO"); |
| @@ -217,7 +216,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 11 unmodified lines | |||
| 217 | 216 | ||
| 218 | _applicationStartupTime = startup_time; | 217 | _applicationStartupTime = startup_time; |
| 219 | 218 | ||
| 220 | QFontDatabase::addApplicationFont(Application::resourcesPath() + "styles/Inconsolata.otf"); | 219 | QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf"); |
| 221 | _window->setWindowTitle("Interface"); | 220 | _window->setWindowTitle("Interface"); |
| 222 | 221 | ||
| 223 | qInstallMessageHandler(messageHandler); | 222 | qInstallMessageHandler(messageHandler); |
| @@ -714,7 +713,7 @@ void Application::paintGL() { · 490 unmodified lines | |||
| 714 | TV3DManager::display(*whichCamera); | 713 | TV3DManager::display(*whichCamera); |
| 715 | 714 | ||
| 716 | } else { | 715 | } else { |
| 717 | _glowEffect.prepare(); | 716 | DependencyManager::get<GlowEffect>()->prepare(); |
| 718 | 717 | ||
| 719 | // Viewport is assigned to the size of the framebuffer | 718 | // Viewport is assigned to the size of the framebuffer |
| 720 | QSize size = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->size(); | 719 | QSize size = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->size(); |
| @@ -733,7 +732,7 @@ void Application::paintGL() { · 12 unmodified lines | |||
| 733 | renderRearViewMirror(_mirrorViewRect); | 732 | renderRearViewMirror(_mirrorViewRect); |
| 734 | } | 733 | } |
| 735 | 734 | ||
| 736 | _glowEffect.render(); | 735 | DependencyManager::get<GlowEffect>()->render(); |
| 737 | 736 | ||
| 738 | { | 737 | { |
| 739 | PerformanceTimer perfTimer("renderOverlay"); | 738 | PerformanceTimer perfTimer("renderOverlay"); |
| @@ -1924,9 +1923,8 @@ void Application::init() { · 1184 unmodified lines | |||
| 1924 | 1923 | ||
| 1925 | _environment.init(); | 1924 | _environment.init(); |
| 1926 | 1925 | ||
| 1927 | _deferredLightingEffect.init(); | 1926 | DependencyManager::get<DeferredLightingEffect>()->init(this); |
| 1928 | _glowEffect.init(); | 1927 | DependencyManager::get<AmbientOcclusionEffect>()->init(this); |
| 1929 | _ambientOcclusionEffect.init(); | ||
| 1930 | 1928 | ||
| 1931 | // TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager | 1929 | // TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager |
| 1932 | _avatarManager.init(); | 1930 | _avatarManager.init(); |
| @@ -2055,6 +2053,9 @@ void Application::init() { · 122 unmodified lines | |||
| 2055 | 2053 | ||
| 2056 | // make sure our texture cache knows about window size changes | 2054 | // make sure our texture cache knows about window size changes |
| 2057 | DependencyManager::get<TextureCache>()->associateWithWidget(getGLWidget()); | 2055 | DependencyManager::get<TextureCache>()->associateWithWidget(getGLWidget()); |
| 2056 | |||
| 2057 | // initialize the GlowEffect with our widget | ||
| 2058 | DependencyManager::get<GlowEffect>()->init(getGLWidget(), Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect)); | ||
| 2058 | } | 2059 | } |
| 2059 | 2060 | ||
| 2060 | void Application::closeMirrorView() { | 2061 | void Application::closeMirrorView() { |
| @@ -2956,6 +2957,10 @@ void Application::setupWorldLight() { · 895 unmodified lines | |||
| 2956 | glMateriali(GL_FRONT, GL_SHININESS, 96); | 2957 | glMateriali(GL_FRONT, GL_SHININESS, 96); |
| 2957 | } | 2958 | } |
| 2958 | 2959 | ||
| 2960 | bool Application::shouldRenderMesh(float largestDimension, float distanceToCamera) { | ||
| 2961 | return Menu::getInstance()->shouldRenderMesh(largestDimension, distanceToCamera); | ||
| 2962 | } | ||
| 2963 | |||
| 2959 | QImage Application::renderAvatarBillboard() { | 2964 | QImage Application::renderAvatarBillboard() { |
| 2960 | DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind(); | 2965 | DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind(); |
| 2961 | 2966 | ||
| @@ -3092,7 +3097,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr · 130 unmodified lines | |||
| 3092 | glEnable(GL_LIGHTING); | 3097 | glEnable(GL_LIGHTING); |
| 3093 | glEnable(GL_DEPTH_TEST); | 3098 | glEnable(GL_DEPTH_TEST); |
| 3094 | 3099 | ||
| 3095 | _deferredLightingEffect.prepare(); | 3100 | DependencyManager::get<DeferredLightingEffect>()->prepare(); |
| 3096 | 3101 | ||
| 3097 | if (!selfAvatarOnly) { | 3102 | if (!selfAvatarOnly) { |
| 3098 | // draw a red sphere | 3103 | // draw a red sphere |
| @@ -3135,7 +3140,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr · 36 unmodified lines | |||
| 3135 | PerformanceTimer perfTimer("ambientOcclusion"); | 3140 | PerformanceTimer perfTimer("ambientOcclusion"); |
| 3136 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 3141 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 3137 | "Application::displaySide() ... AmbientOcclusion..."); | 3142 | "Application::displaySide() ... AmbientOcclusion..."); |
| 3138 | _ambientOcclusionEffect.render(); | 3143 | DependencyManager::get<AmbientOcclusionEffect>()->render(); |
| 3139 | } | 3144 | } |
| 3140 | } | 3145 | } |
| 3141 | 3146 | ||
| @@ -3152,7 +3157,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr · 10 unmodified lines | |||
| 3152 | { | 3157 | { |
| 3153 | PROFILE_RANGE("DeferredLighting"); | 3158 | PROFILE_RANGE("DeferredLighting"); |
| 3154 | PerformanceTimer perfTimer("lighting"); | 3159 | PerformanceTimer perfTimer("lighting"); |
| 3155 | _deferredLightingEffect.render(); | 3160 | DependencyManager::get<DeferredLightingEffect>()->render(); |
| 3156 | } | 3161 | } |
| 3157 | 3162 | ||
| 3158 | { | 3163 | { |
| @@ -3257,6 +3262,14 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom · 98 unmodified lines | |||
| 3257 | } | 3262 | } |
| 3258 | } | 3263 | } |
| 3259 | 3264 | ||
| 3265 | bool Application::getShadowsEnabled() { | ||
| 3266 | return Menu::getInstance()->getShadowsEnabled(); | ||
| 3267 | } | ||
| 3268 | |||
| 3269 | bool Application::getCascadeShadowsEnabled() { | ||
| 3270 | return Menu::getInstance()->isOptionChecked(MenuOption::CascadedShadows); | ||
| 3271 | } | ||
| 3272 | |||
| 3260 | glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { | 3273 | glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { |
| 3261 | float horizontalScale = _glWidget->getDeviceWidth() / 2.0f; | 3274 | float horizontalScale = _glWidget->getDeviceWidth() / 2.0f; |
| 3262 | float verticalScale = _glWidget->getDeviceHeight() / 2.0f; | 3275 | float verticalScale = _glWidget->getDeviceHeight() / 2.0f; |
| @@ -4025,7 +4038,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 762 unmodified lines | |||
| 4025 | scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance()); | 4038 | scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance()); |
| 4026 | scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance()); | 4039 | scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance()); |
| 4027 | scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance()); | 4040 | scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance()); |
| 4028 | scriptEngine->registerGlobalObject("AnimationCache", &_animationCache); | 4041 | scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>()); |
| 4029 | scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance()); | 4042 | scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance()); |
| 4030 | scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance()); | 4043 | scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance()); |
| 4031 | scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels); | 4044 | scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels); |
| @@ -4406,7 +4419,7 @@ void Application::skipVersion(QString latestVersion) { · 374 unmodified lines | |||
| 4406 | 4419 | ||
| 4407 | void Application::takeSnapshot() { | 4420 | void Application::takeSnapshot() { |
| 4408 | QMediaPlayer* player = new QMediaPlayer(); | 4421 | QMediaPlayer* player = new QMediaPlayer(); |
| 4409 | QFileInfo inf = QFileInfo(Application::resourcesPath() + "sounds/snap.wav"); | 4422 | QFileInfo inf = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav"); |
| 4410 | player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); | 4423 | player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); |
| 4411 | player->play(); | 4424 | player->play(); |
| 4412 | 4425 | ||