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
5454
5555 #include <AddressManager.h>
5656 #include <AccountManager.h>
57+#include <AmbientOcclusionEffect.h>
5758 #include <AudioInjector.h>
59+#include <DeferredLightingEffect.h>
5860 #include <DependencyManager.h>
5961 #include <EntityScriptingInterface.h>
62+#include <GlowEffect.h>
6063 #include <HFActionEvent.h>
6164 #include <HFBackEvent.h>
6265 #include <LocalVoxelsList.h>
@@ -66,7 +69,9 @@ · 3 unmodified lines
6669 #include <OctalCode.h>
6770 #include <OctreeSceneStats.h>
6871 #include <PacketHeaders.h>
72+#include <PathUtils.h>
6973 #include <PerfStat.h>
74+#include <ProgramObject.h>
7075 #include <ResourceCache.h>
7176 #include <SoundCache.h>
7277 #include <UserActivityLogger.h>
@@ -86,10 +91,10 @@ · 13 unmodified lines
8691 #include "devices/TV3DManager.h"
8792 #include "devices/Visage.h"
8893
89−#include "renderer/ProgramObject.h"
9094 #include "gpu/Batch.h"
9195 #include "gpu/GLBackend.h"
9296
97+
9398 #include "scripting/AccountScriptingInterface.h"
9499 #include "scripting/AudioDeviceScriptingInterface.h"
95100 #include "scripting/ClipboardScriptingInterface.h"
@@ -108,6 +113,7 @@ · 12 unmodified lines
108113 #include "ui/TextRenderer.h"
109114
110115
116+
111117 using namespace std;
112118
113119 // Starfield information
@@ -134,15 +140,6 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt · 20 unmodified lines
134140 }
135141 }
136142
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−
146143 Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
147144 QApplication(argc, argv),
148145 _window(new MainWindow(desktop())),
@@ -195,9 +192,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 46 unmodified lines
195192 _aboutToQuit(false)
196193 {
197194 GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
195+ Model::setViewStateInterface(this); // The model class will sometimes need to know view state details from us
198196
199197 // 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);
201199
202200 // set the associated application properties
203201 applicationInfo.beginGroup("INFO");
@@ -215,7 +213,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 11 unmodified lines
215213
216214 _applicationStartupTime = startup_time;
217215
218− QFontDatabase::addApplicationFont(Application::resourcesPath() + "styles/Inconsolata.otf");
216+ QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf");
219217 _window->setWindowTitle("Interface");
220218
221219 qInstallMessageHandler(messageHandler);
@@ -711,7 +709,7 @@ void Application::paintGL() { · 489 unmodified lines
711709 TV3DManager::display(*whichCamera);
712710
713711 } else {
714− _glowEffect.prepare();
712+ DependencyManager::get<GlowEffect>()->prepare();
715713
716714 // Viewport is assigned to the size of the framebuffer
717715 QSize size = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->size();
@@ -730,7 +728,7 @@ void Application::paintGL() { · 12 unmodified lines
730728 renderRearViewMirror(_mirrorViewRect);
731729 }
732730
733− _glowEffect.render();
731+ DependencyManager::get<GlowEffect>()->render();
734732
735733 {
736734 PerformanceTimer perfTimer("renderOverlay");
@@ -1928,9 +1926,8 @@ void Application::init() { · 1191 unmodified lines
19281926
19291927 _environment.init();
19301928
1931− _deferredLightingEffect.init();
1932− _glowEffect.init();
1933− _ambientOcclusionEffect.init();
1929+ DependencyManager::get<DeferredLightingEffect>()->init(this);
1930+ DependencyManager::get<AmbientOcclusionEffect>()->init(this);
19341931
19351932 // TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager
19361933 _avatarManager.init();
@@ -2050,8 +2047,12 @@ void Application::init() { · 113 unmodified lines
20502047 // save settings when avatar changes
20512048 connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings);
20522049
2053− // make sure our texture cache knows about window size changes
2050+ // make sure our texture cache knows about window size changes
20542051 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));
20552056 }
20562057
20572058 void Application::closeMirrorView() {
@@ -2947,6 +2948,10 @@ void Application::setupWorldLight() { · 889 unmodified lines
29472948 glMateriali(GL_FRONT, GL_SHININESS, 96);
29482949 }
29492950
2951+bool Application::shouldRenderMesh(float largestDimension, float distanceToCamera) {
2952+ return Menu::getInstance()->shouldRenderMesh(largestDimension, distanceToCamera);
2953+}
2954+
29502955 QImage Application::renderAvatarBillboard() {
29512956 DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind();
29522957
@@ -3085,7 +3090,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr · 132 unmodified lines
30853090 glEnable(GL_LIGHTING);
30863091 glEnable(GL_DEPTH_TEST);
30873092
3088− _deferredLightingEffect.prepare();
3093+ DependencyManager::get<DeferredLightingEffect>()->prepare();
30893094
30903095 if (!selfAvatarOnly) {
30913096 // draw a red sphere
@@ -3128,7 +3133,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr · 36 unmodified lines
31283133 PerformanceTimer perfTimer("ambientOcclusion");
31293134 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
31303135 "Application::displaySide() ... AmbientOcclusion...");
3131− _ambientOcclusionEffect.render();
3136+ DependencyManager::get<AmbientOcclusionEffect>()->render();
31323137 }
31333138 }
31343139
@@ -3145,7 +3150,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr · 10 unmodified lines
31453150 {
31463151 PROFILE_RANGE("DeferredLighting");
31473152 PerformanceTimer perfTimer("lighting");
3148− _deferredLightingEffect.render();
3153+ DependencyManager::get<DeferredLightingEffect>()->render();
31493154 }
31503155
31513156 {
@@ -3250,6 +3255,14 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom · 98 unmodified lines
32503255 }
32513256 }
32523257
3258+bool Application::getShadowsEnabled() {
3259+ return Menu::getInstance()->getShadowsEnabled();
3260+}
3261+
3262+bool Application::getCascadeShadowsEnabled() {
3263+ return Menu::getInstance()->isOptionChecked(MenuOption::CascadedShadows);
3264+}
3265+
32533266 glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) {
32543267 GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
32553268 float horizontalScale = glCanvas->getDeviceWidth() / 2.0f;
@@ -4019,7 +4032,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 763 unmodified lines
40194032 scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());
40204033 scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
40214034 scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());
4022− scriptEngine->registerGlobalObject("AnimationCache", &_animationCache);
4035+ scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>());
40234036 scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance());
40244037 scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance());
40254038 scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels);
@@ -4382,7 +4395,7 @@ void Application::skipVersion(QString latestVersion) { · 356 unmodified lines
43824395
43834396 void Application::takeSnapshot() {
43844397 QMediaPlayer* player = new QMediaPlayer();
4385− QFileInfo inf = QFileInfo(Application::resourcesPath() + "sounds/snap.wav");
4398+ QFileInfo inf = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav");
43864399 player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));
43874400 player->play();
43884401

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