History

Merge branch 'master' of https://github.com/highfidelity/hifi into applications_diet

Atlante45 committed 11 years ago

Commit 11a2eca2 parents 2039895 7632dbe92 files · +607 −340Browse files

Showing the changes to interface/src/Application.cpp (1 of 92 files). Show all

Unified · Split

interface/src/Application.cpp+36−23
@@ -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>
@@ -66,7 +69,9 @@ · 3 unmodified lines
66#include <OctalCode.h>69#include <OctalCode.h>
67#include <OctreeSceneStats.h>70#include <OctreeSceneStats.h>
68#include <PacketHeaders.h>71#include <PacketHeaders.h>
72#include <PathUtils.h>
69#include <PerfStat.h>73#include <PerfStat.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
111using namespace std;117using namespace std;
112 118
113// Starfield information119// Starfield information
@@ -134,15 +140,6 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt · 20 unmodified lines
134 }140 }
135}141}
136 142
137QString& 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
146Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :143Application::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())),
@@ -195,9 +192,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 46 unmodified lines
195 _aboutToQuit(false)192 _aboutToQuit(false)
196{193{
197 GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();194 GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
195 Model::setViewStateInterface(this); // The model class will sometimes need to know view state details from us
198 196
199 // read the ApplicationInfo.ini file for Name/Version/Domain information197 // read the ApplicationInfo.ini file for Name/Version/Domain information
200 QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);198 QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
201 199
202 // set the associated application properties200 // set the associated application properties
203 applicationInfo.beginGroup("INFO");201 applicationInfo.beginGroup("INFO");
@@ -215,7 +213,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 11 unmodified lines
215 213
216 _applicationStartupTime = startup_time;214 _applicationStartupTime = startup_time;
217 215
218 QFontDatabase::addApplicationFont(Application::resourcesPath() + "styles/Inconsolata.otf");216 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf");
219 _window->setWindowTitle("Interface");217 _window->setWindowTitle("Interface");
220 218
221 qInstallMessageHandler(messageHandler);219 qInstallMessageHandler(messageHandler);
@@ -711,7 +709,7 @@ void Application::paintGL() { · 489 unmodified lines
711 TV3DManager::display(*whichCamera);709 TV3DManager::display(*whichCamera);
712 710
713 } else {711 } else {
714 _glowEffect.prepare();712 DependencyManager::get<GlowEffect>()->prepare();
715 713
716 // Viewport is assigned to the size of the framebuffer714 // Viewport is assigned to the size of the framebuffer
717 QSize size = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->size();715 QSize size = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->size();
@@ -730,7 +728,7 @@ void Application::paintGL() { · 12 unmodified lines
730 renderRearViewMirror(_mirrorViewRect); 728 renderRearViewMirror(_mirrorViewRect);
731 }729 }
732 730
733 _glowEffect.render();731 DependencyManager::get<GlowEffect>()->render();
734 732
735 {733 {
736 PerformanceTimer perfTimer("renderOverlay");734 PerformanceTimer perfTimer("renderOverlay");
@@ -1928,9 +1926,8 @@ void Application::init() { · 1191 unmodified lines
1928 1926
1929 _environment.init();1927 _environment.init();
1930 1928
1931 _deferredLightingEffect.init();1929 DependencyManager::get<DeferredLightingEffect>()->init(this);
1932 _glowEffect.init();1930 DependencyManager::get<AmbientOcclusionEffect>()->init(this);
1933 _ambientOcclusionEffect.init();
1934 1931
1935 // TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager1932 // TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager
1936 _avatarManager.init();1933 _avatarManager.init();
@@ -2050,8 +2047,12 @@ void Application::init() { · 113 unmodified lines
2050 // save settings when avatar changes2047 // save settings when avatar changes
2051 connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings);2048 connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings);
2052 2049
2053 // make sure our texture cache knows about window size changes 2050 // make sure our texture cache knows about window size changes
2054 DependencyManager::get<TextureCache>()->associateWithWidget(glCanvas.data());2051 DependencyManager::get<TextureCache>()->associateWithWidget(glCanvas.data());
2052
2053 // initialize the GlowEffect with our widget
2054 DependencyManager::get<GlowEffect>()->init(glCanvas,
2055 Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect));
2055}2056}
2056 2057
2057void Application::closeMirrorView() {2058void Application::closeMirrorView() {
@@ -2947,6 +2948,10 @@ void Application::setupWorldLight() { · 889 unmodified lines
2947 glMateriali(GL_FRONT, GL_SHININESS, 96);2948 glMateriali(GL_FRONT, GL_SHININESS, 96);
2948}2949}
2949 2950
2951bool Application::shouldRenderMesh(float largestDimension, float distanceToCamera) {
2952 return Menu::getInstance()->shouldRenderMesh(largestDimension, distanceToCamera);
2953}
2954
2950QImage Application::renderAvatarBillboard() {2955QImage Application::renderAvatarBillboard() {
2951 DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind();2956 DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind();
2952 2957
@@ -3085,7 +3090,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr · 132 unmodified lines
3085 glEnable(GL_LIGHTING);3090 glEnable(GL_LIGHTING);
3086 glEnable(GL_DEPTH_TEST);3091 glEnable(GL_DEPTH_TEST);
3087 3092
3088 _deferredLightingEffect.prepare();3093 DependencyManager::get<DeferredLightingEffect>()->prepare();
3089 3094
3090 if (!selfAvatarOnly) {3095 if (!selfAvatarOnly) {
3091 // draw a red sphere3096 // draw a red sphere
@@ -3128,7 +3133,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr · 36 unmodified lines
3128 PerformanceTimer perfTimer("ambientOcclusion");3133 PerformanceTimer perfTimer("ambientOcclusion");
3129 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),3134 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
3130 "Application::displaySide() ... AmbientOcclusion...");3135 "Application::displaySide() ... AmbientOcclusion...");
3131 _ambientOcclusionEffect.render();3136 DependencyManager::get<AmbientOcclusionEffect>()->render();
3132 }3137 }
3133 }3138 }
3134 3139
@@ -3145,7 +3150,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr · 10 unmodified lines
3145 {3150 {
3146 PROFILE_RANGE("DeferredLighting"); 3151 PROFILE_RANGE("DeferredLighting");
3147 PerformanceTimer perfTimer("lighting");3152 PerformanceTimer perfTimer("lighting");
3148 _deferredLightingEffect.render();3153 DependencyManager::get<DeferredLightingEffect>()->render();
3149 }3154 }
3150 3155
3151 {3156 {
@@ -3250,6 +3255,14 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom · 98 unmodified lines
3250 }3255 }
3251}3256}
3252 3257
3258bool Application::getShadowsEnabled() {
3259 return Menu::getInstance()->getShadowsEnabled();
3260}
3261
3262bool Application::getCascadeShadowsEnabled() {
3263 return Menu::getInstance()->isOptionChecked(MenuOption::CascadedShadows);
3264}
3265
3253glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) {3266glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) {
3254 GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();3267 GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
3255 float horizontalScale = glCanvas->getDeviceWidth() / 2.0f;3268 float horizontalScale = glCanvas->getDeviceWidth() / 2.0f;
@@ -4019,7 +4032,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 763 unmodified lines
4019 scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());4032 scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());
4020 scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());4033 scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
4021 scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());4034 scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());
4022 scriptEngine->registerGlobalObject("AnimationCache", &_animationCache);4035 scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>());
4023 scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance());4036 scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance());
4024 scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance());4037 scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance());
4025 scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels);4038 scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels);
@@ -4382,7 +4395,7 @@ void Application::skipVersion(QString latestVersion) { · 356 unmodified lines
4382 4395
4383void Application::takeSnapshot() {4396void Application::takeSnapshot() {
4384 QMediaPlayer* player = new QMediaPlayer();4397 QMediaPlayer* player = new QMediaPlayer();
4385 QFileInfo inf = QFileInfo(Application::resourcesPath() + "sounds/snap.wav");4398 QFileInfo inf = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav");
4386 player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));4399 player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));
4387 player->play();4400 player->play();
4388 4401

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t