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 | 55 | #include <AddressManager.h> |
| 56 | 56 | #include <AccountManager.h> |
| 57 | +#include <AmbientOcclusionEffect.h> | |
| 57 | 58 | #include <AudioInjector.h> |
| 59 | +#include <DeferredLightingEffect.h> | |
| 58 | 60 | #include <DependencyManager.h> |
| 59 | 61 | #include <EntityScriptingInterface.h> |
| 62 | +#include <GlowEffect.h> | |
| 60 | 63 | #include <HFActionEvent.h> |
| 61 | 64 | #include <HFBackEvent.h> |
| 62 | 65 | #include <LocalVoxelsList.h> |
| @@ -65,8 +68,10 @@ · 2 unmodified lines | ||
| 65 | 68 | #include <OctalCode.h> |
| 66 | 69 | #include <OctreeSceneStats.h> |
| 67 | 70 | #include <PacketHeaders.h> |
| 71 | +#include <PathUtils.h> | |
| 68 | 72 | #include <PerfStat.h> |
| 69 | 73 | #include <PhysicsEngine.h> |
| 74 | +#include <ProgramObject.h> | |
| 70 | 75 | #include <ResourceCache.h> |
| 71 | 76 | #include <SoundCache.h> |
| 72 | 77 | #include <UserActivityLogger.h> |
| @@ -86,10 +91,10 @@ · 13 unmodified lines | ||
| 86 | 91 | #include "devices/TV3DManager.h" |
| 87 | 92 | #include "devices/Visage.h" |
| 88 | 93 | |
| 89 | −#include "renderer/ProgramObject.h" | |
| 90 | 94 | #include "gpu/Batch.h" |
| 91 | 95 | #include "gpu/GLBackend.h" |
| 92 | 96 | |
| 97 | + | |
| 93 | 98 | #include "scripting/AccountScriptingInterface.h" |
| 94 | 99 | #include "scripting/AudioDeviceScriptingInterface.h" |
| 95 | 100 | #include "scripting/ClipboardScriptingInterface.h" |
| @@ -108,6 +113,7 @@ · 12 unmodified lines | ||
| 108 | 113 | #include "ui/TextRenderer.h" |
| 109 | 114 | |
| 110 | 115 | |
| 116 | + | |
| 111 | 117 | using namespace std; |
| 112 | 118 | |
| 113 | 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 | 143 | Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : |
| 147 | 144 | QApplication(argc, argv), |
| 148 | 145 | _window(new MainWindow(desktop())), |
| @@ -198,8 +195,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 49 unmodified lines | ||
| 198 | 195 | _isVSyncOn(true), |
| 199 | 196 | _aboutToQuit(false) |
| 200 | 197 | { |
| 198 | + Model::setViewStateInterface(this); // The model class will sometimes need to know view state details from us | |
| 199 | + | |
| 201 | 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 | 203 | // set the associated application properties |
| 205 | 204 | applicationInfo.beginGroup("INFO"); |
| @@ -217,7 +216,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 11 unmodified lines | ||
| 217 | 216 | |
| 218 | 217 | _applicationStartupTime = startup_time; |
| 219 | 218 | |
| 220 | − QFontDatabase::addApplicationFont(Application::resourcesPath() + "styles/Inconsolata.otf"); | |
| 219 | + QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf"); | |
| 221 | 220 | _window->setWindowTitle("Interface"); |
| 222 | 221 | |
| 223 | 222 | qInstallMessageHandler(messageHandler); |
| @@ -714,7 +713,7 @@ void Application::paintGL() { · 490 unmodified lines | ||
| 714 | 713 | TV3DManager::display(*whichCamera); |
| 715 | 714 | |
| 716 | 715 | } else { |
| 717 | − _glowEffect.prepare(); | |
| 716 | + DependencyManager::get<GlowEffect>()->prepare(); | |
| 718 | 717 | |
| 719 | 718 | // Viewport is assigned to the size of the framebuffer |
| 720 | 719 | QSize size = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->size(); |
| @@ -733,7 +732,7 @@ void Application::paintGL() { · 12 unmodified lines | ||
| 733 | 732 | renderRearViewMirror(_mirrorViewRect); |
| 734 | 733 | } |
| 735 | 734 | |
| 736 | − _glowEffect.render(); | |
| 735 | + DependencyManager::get<GlowEffect>()->render(); | |
| 737 | 736 | |
| 738 | 737 | { |
| 739 | 738 | PerformanceTimer perfTimer("renderOverlay"); |
| @@ -1924,9 +1923,8 @@ void Application::init() { · 1184 unmodified lines | ||
| 1924 | 1923 | |
| 1925 | 1924 | _environment.init(); |
| 1926 | 1925 | |
| 1927 | − _deferredLightingEffect.init(); | |
| 1928 | − _glowEffect.init(); | |
| 1929 | − _ambientOcclusionEffect.init(); | |
| 1926 | + DependencyManager::get<DeferredLightingEffect>()->init(this); | |
| 1927 | + DependencyManager::get<AmbientOcclusionEffect>()->init(this); | |
| 1930 | 1928 | |
| 1931 | 1929 | // TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager |
| 1932 | 1930 | _avatarManager.init(); |
| @@ -2055,6 +2053,9 @@ void Application::init() { · 122 unmodified lines | ||
| 2055 | 2053 | |
| 2056 | 2054 | // make sure our texture cache knows about window size changes |
| 2057 | 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 | 2061 | void Application::closeMirrorView() { |
| @@ -2956,6 +2957,10 @@ void Application::setupWorldLight() { · 895 unmodified lines | ||
| 2956 | 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 | 2964 | QImage Application::renderAvatarBillboard() { |
| 2960 | 2965 | DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind(); |
| 2961 | 2966 | |
| @@ -3092,7 +3097,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr · 130 unmodified lines | ||
| 3092 | 3097 | glEnable(GL_LIGHTING); |
| 3093 | 3098 | glEnable(GL_DEPTH_TEST); |
| 3094 | 3099 | |
| 3095 | − _deferredLightingEffect.prepare(); | |
| 3100 | + DependencyManager::get<DeferredLightingEffect>()->prepare(); | |
| 3096 | 3101 | |
| 3097 | 3102 | if (!selfAvatarOnly) { |
| 3098 | 3103 | // draw a red sphere |
| @@ -3135,7 +3140,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr · 36 unmodified lines | ||
| 3135 | 3140 | PerformanceTimer perfTimer("ambientOcclusion"); |
| 3136 | 3141 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 3137 | 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 | 3158 | PROFILE_RANGE("DeferredLighting"); |
| 3154 | 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 | 3273 | glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { |
| 3261 | 3274 | float horizontalScale = _glWidget->getDeviceWidth() / 2.0f; |
| 3262 | 3275 | float verticalScale = _glWidget->getDeviceHeight() / 2.0f; |
| @@ -4025,7 +4038,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 762 unmodified lines | ||
| 4025 | 4038 | scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance()); |
| 4026 | 4039 | scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance()); |
| 4027 | 4040 | scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance()); |
| 4028 | − scriptEngine->registerGlobalObject("AnimationCache", &_animationCache); | |
| 4041 | + scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>()); | |
| 4029 | 4042 | scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance()); |
| 4030 | 4043 | scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance()); |
| 4031 | 4044 | scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels); |
| @@ -4406,7 +4419,7 @@ void Application::skipVersion(QString latestVersion) { · 374 unmodified lines | ||
| 4406 | 4419 | |
| 4407 | 4420 | void Application::takeSnapshot() { |
| 4408 | 4421 | QMediaPlayer* player = new QMediaPlayer(); |
| 4409 | − QFileInfo inf = QFileInfo(Application::resourcesPath() + "sounds/snap.wav"); | |
| 4422 | + QFileInfo inf = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav"); | |
| 4410 | 4423 | player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); |
| 4411 | 4424 | player->play(); |
| 4412 | 4425 | |