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

This commit is contained in:
Andrzej Kapolka 2014-12-16 17:07:16 -08:00
commit ab52f434c9
93 changed files with 607 additions and 346 deletions

View file

@ -28,7 +28,7 @@ void ScriptableAvatar::startAnimation(const QString& url, float fps, float prior
Q_ARG(float, lastFrame), Q_ARG(const QStringList&, maskedJoints)); Q_ARG(float, lastFrame), Q_ARG(const QStringList&, maskedJoints));
return; return;
} }
_animation = _scriptEngine->getAnimationCache()->getAnimation(url); _animation = DependencyManager::get<AnimationCache>()->getAnimation(url);
_animationDetails = AnimationDetails("", QUrl(url), fps, 0, loop, hold, false, firstFrame, lastFrame, true, firstFrame); _animationDetails = AnimationDetails("", QUrl(url), fps, 0, loop, hold, false, firstFrame, lastFrame, true, firstFrame);
_maskedJoints = maskedJoints; _maskedJoints = maskedJoints;
} }

View file

@ -23,12 +23,8 @@ function setupMenus() {
Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Display Model Element Bounds", isCheckable: true, isChecked: false }); Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Display Model Element Bounds", isCheckable: true, isChecked: false });
Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Display Model Element Children", isCheckable: true, isChecked: false }); Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Display Model Element Children", isCheckable: true, isChecked: false });
Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Don't Do Precision Picking", isCheckable: true, isChecked: false }); Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Don't Do Precision Picking", isCheckable: true, isChecked: false });
Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Don't Attempt to Reduce Material Switches", isCheckable: true, isChecked: false });
Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Don't Attempt Render Entities as Scene", isCheckable: true, isChecked: false }); Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Don't Attempt Render Entities as Scene", isCheckable: true, isChecked: false });
Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Don't Do Precision Picking", isCheckable: true, isChecked: false }); Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Don't Do Precision Picking", isCheckable: true, isChecked: false });
Menu.addMenu("Developer > Entities > Culling");
Menu.addMenuItem({ menuName: "Developer > Entities > Culling", menuItemName: "Don't Cull Out Of View Mesh Parts", isCheckable: true, isChecked: false });
Menu.addMenuItem({ menuName: "Developer > Entities > Culling", menuItemName: "Don't Cull Too Small Mesh Parts", isCheckable: true, isChecked: false });
Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Disable Light Entities", isCheckable: true, isChecked: false }); Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Disable Light Entities", isCheckable: true, isChecked: false });
} }
} }

View file

@ -107,7 +107,7 @@ endif()
add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS} ${QM}) add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS} ${QM})
# link required hifi libraries # link required hifi libraries
link_hifi_libraries(shared octree voxels gpu fbx metavoxels networking entities avatars audio animation script-engine physics) link_hifi_libraries(shared octree voxels gpu fbx metavoxels networking entities avatars audio animation script-engine physics render-utils)
# find any optional and required libraries # find any optional and required libraries
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)

View file

@ -54,9 +54,12 @@
#include <AddressManager.h> #include <AddressManager.h>
#include <AccountManager.h> #include <AccountManager.h>
#include <AmbientOcclusionEffect.h>
#include <AudioInjector.h> #include <AudioInjector.h>
#include <DeferredLightingEffect.h>
#include <DependencyManager.h> #include <DependencyManager.h>
#include <EntityScriptingInterface.h> #include <EntityScriptingInterface.h>
#include <GlowEffect.h>
#include <HFActionEvent.h> #include <HFActionEvent.h>
#include <HFBackEvent.h> #include <HFBackEvent.h>
#include <LocalVoxelsList.h> #include <LocalVoxelsList.h>
@ -65,7 +68,9 @@
#include <OctalCode.h> #include <OctalCode.h>
#include <OctreeSceneStats.h> #include <OctreeSceneStats.h>
#include <PacketHeaders.h> #include <PacketHeaders.h>
#include <PathUtils.h>
#include <PerfStat.h> #include <PerfStat.h>
#include <ProgramObject.h>
#include <ResourceCache.h> #include <ResourceCache.h>
#include <SoundCache.h> #include <SoundCache.h>
#include <UserActivityLogger.h> #include <UserActivityLogger.h>
@ -85,10 +90,10 @@
#include "devices/TV3DManager.h" #include "devices/TV3DManager.h"
#include "devices/Visage.h" #include "devices/Visage.h"
#include "renderer/ProgramObject.h"
#include "gpu/Batch.h" #include "gpu/Batch.h"
#include "gpu/GLBackend.h" #include "gpu/GLBackend.h"
#include "scripting/AccountScriptingInterface.h" #include "scripting/AccountScriptingInterface.h"
#include "scripting/AudioDeviceScriptingInterface.h" #include "scripting/AudioDeviceScriptingInterface.h"
#include "scripting/ClipboardScriptingInterface.h" #include "scripting/ClipboardScriptingInterface.h"
@ -107,6 +112,7 @@
#include "ui/TextRenderer.h" #include "ui/TextRenderer.h"
using namespace std; using namespace std;
// Starfield information // Starfield information
@ -133,15 +139,6 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt
} }
} }
QString& Application::resourcesPath() {
#ifdef Q_OS_MAC
static QString staticResourcePath = QCoreApplication::applicationDirPath() + "/../Resources/";
#else
static QString staticResourcePath = QCoreApplication::applicationDirPath() + "/resources/";
#endif
return staticResourcePath;
}
Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
QApplication(argc, argv), QApplication(argc, argv),
_window(new MainWindow(desktop())), _window(new MainWindow(desktop())),
@ -194,8 +191,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
_isVSyncOn(true), _isVSyncOn(true),
_aboutToQuit(false) _aboutToQuit(false)
{ {
Model::setViewStateInterface(this); // The model class will sometimes need to know view state details from us
// read the ApplicationInfo.ini file for Name/Version/Domain information // read the ApplicationInfo.ini file for Name/Version/Domain information
QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
// set the associated application properties // set the associated application properties
applicationInfo.beginGroup("INFO"); applicationInfo.beginGroup("INFO");
@ -213,7 +212,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
_applicationStartupTime = startup_time; _applicationStartupTime = startup_time;
QFontDatabase::addApplicationFont(Application::resourcesPath() + "styles/Inconsolata.otf"); QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf");
_window->setWindowTitle("Interface"); _window->setWindowTitle("Interface");
qInstallMessageHandler(messageHandler); qInstallMessageHandler(messageHandler);
@ -710,7 +709,7 @@ void Application::paintGL() {
TV3DManager::display(*whichCamera); TV3DManager::display(*whichCamera);
} else { } else {
_glowEffect.prepare(); DependencyManager::get<GlowEffect>()->prepare();
// Viewport is assigned to the size of the framebuffer // Viewport is assigned to the size of the framebuffer
QSize size = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->size(); QSize size = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->size();
@ -729,7 +728,7 @@ void Application::paintGL() {
renderRearViewMirror(_mirrorViewRect); renderRearViewMirror(_mirrorViewRect);
} }
_glowEffect.render(); DependencyManager::get<GlowEffect>()->render();
{ {
PerformanceTimer perfTimer("renderOverlay"); PerformanceTimer perfTimer("renderOverlay");
@ -1920,9 +1919,8 @@ void Application::init() {
_environment.init(); _environment.init();
_deferredLightingEffect.init(); DependencyManager::get<DeferredLightingEffect>()->init(this);
_glowEffect.init(); DependencyManager::get<AmbientOcclusionEffect>()->init(this);
_ambientOcclusionEffect.init();
// TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager // TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager
_avatarManager.init(); _avatarManager.init();
@ -2044,6 +2042,9 @@ void Application::init() {
// make sure our texture cache knows about window size changes // make sure our texture cache knows about window size changes
DependencyManager::get<TextureCache>()->associateWithWidget(getGLWidget()); DependencyManager::get<TextureCache>()->associateWithWidget(getGLWidget());
// initialize the GlowEffect with our widget
DependencyManager::get<GlowEffect>()->init(getGLWidget(), Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect));
} }
void Application::closeMirrorView() { void Application::closeMirrorView() {
@ -2938,6 +2939,10 @@ void Application::setupWorldLight() {
glMateriali(GL_FRONT, GL_SHININESS, 96); glMateriali(GL_FRONT, GL_SHININESS, 96);
} }
bool Application::shouldRenderMesh(float largestDimension, float distanceToCamera) {
return Menu::getInstance()->shouldRenderMesh(largestDimension, distanceToCamera);
}
QImage Application::renderAvatarBillboard() { QImage Application::renderAvatarBillboard() {
DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind(); DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind();
@ -3074,7 +3079,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
_deferredLightingEffect.prepare(); DependencyManager::get<DeferredLightingEffect>()->prepare();
if (!selfAvatarOnly) { if (!selfAvatarOnly) {
// draw a red sphere // draw a red sphere
@ -3117,7 +3122,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr
PerformanceTimer perfTimer("ambientOcclusion"); PerformanceTimer perfTimer("ambientOcclusion");
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... AmbientOcclusion..."); "Application::displaySide() ... AmbientOcclusion...");
_ambientOcclusionEffect.render(); DependencyManager::get<AmbientOcclusionEffect>()->render();
} }
} }
@ -3134,7 +3139,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr
{ {
PROFILE_RANGE("DeferredLighting"); PROFILE_RANGE("DeferredLighting");
PerformanceTimer perfTimer("lighting"); PerformanceTimer perfTimer("lighting");
_deferredLightingEffect.render(); DependencyManager::get<DeferredLightingEffect>()->render();
} }
{ {
@ -3239,6 +3244,14 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom
} }
} }
bool Application::getShadowsEnabled() {
return Menu::getInstance()->getShadowsEnabled();
}
bool Application::getCascadeShadowsEnabled() {
return Menu::getInstance()->isOptionChecked(MenuOption::CascadedShadows);
}
glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) {
float horizontalScale = _glWidget->getDeviceWidth() / 2.0f; float horizontalScale = _glWidget->getDeviceWidth() / 2.0f;
float verticalScale = _glWidget->getDeviceHeight() / 2.0f; float verticalScale = _glWidget->getDeviceHeight() / 2.0f;
@ -4007,7 +4020,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance()); scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());
scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance()); scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance()); scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());
scriptEngine->registerGlobalObject("AnimationCache", &_animationCache); scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>());
scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance()); scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance());
scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance()); scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance());
scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels); scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels);
@ -4369,7 +4382,7 @@ void Application::skipVersion(QString latestVersion) {
void Application::takeSnapshot() { void Application::takeSnapshot() {
QMediaPlayer* player = new QMediaPlayer(); QMediaPlayer* player = new QMediaPlayer();
QFileInfo inf = QFileInfo(Application::resourcesPath() + "sounds/snap.wav"); QFileInfo inf = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav");
player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));
player->play(); player->play();

View file

@ -15,6 +15,8 @@
#include <map> #include <map>
#include <time.h> #include <time.h>
#include <gpu/GPUConfig.h>
#include <QApplication> #include <QApplication>
#include <QMainWindow> #include <QMainWindow>
#include <QAction> #include <QAction>
@ -32,12 +34,15 @@
#include <EntityCollisionSystem.h> #include <EntityCollisionSystem.h>
#include <EntityEditPacketSender.h> #include <EntityEditPacketSender.h>
#include <GeometryCache.h>
#include <NetworkPacket.h> #include <NetworkPacket.h>
#include <NodeList.h> #include <NodeList.h>
#include <OctreeQuery.h> #include <OctreeQuery.h>
#include <PacketHeaders.h> #include <PacketHeaders.h>
#include <ScriptEngine.h> #include <ScriptEngine.h>
#include <TextureCache.h>
#include <ViewFrustum.h> #include <ViewFrustum.h>
#include <ViewStateInterface.h>
#include <VoxelEditPacketSender.h> #include <VoxelEditPacketSender.h>
#include "MainWindow.h" #include "MainWindow.h"
@ -57,11 +62,6 @@
#include "devices/PrioVR.h" #include "devices/PrioVR.h"
#include "devices/SixenseManager.h" #include "devices/SixenseManager.h"
#include "entities/EntityTreeRenderer.h" #include "entities/EntityTreeRenderer.h"
#include "renderer/AmbientOcclusionEffect.h"
#include "renderer/DeferredLightingEffect.h"
#include "renderer/GeometryCache.h"
#include "renderer/GlowEffect.h"
#include "renderer/TextureCache.h"
#include "scripting/ControllerScriptingInterface.h" #include "scripting/ControllerScriptingInterface.h"
#include "ui/BandwidthDialog.h" #include "ui/BandwidthDialog.h"
#include "ui/BandwidthMeter.h" #include "ui/BandwidthMeter.h"
@ -127,7 +127,7 @@ static const quint64 TOO_LONG_SINCE_LAST_SEND_DOWNSTREAM_AUDIO_STATS = 1 * USECS
static const QString INFO_HELP_PATH = "html/interface-welcome-allsvg.html"; static const QString INFO_HELP_PATH = "html/interface-welcome-allsvg.html";
static const QString INFO_EDIT_ENTITIES_PATH = "html/edit-entities-commands.html"; static const QString INFO_EDIT_ENTITIES_PATH = "html/edit-entities-commands.html";
class Application : public QApplication { class Application : public QApplication, public ViewStateInterface {
Q_OBJECT Q_OBJECT
friend class OctreePacketProcessor; friend class OctreePacketProcessor;
@ -136,7 +136,6 @@ class Application : public QApplication {
public: public:
static Application* getInstance() { return static_cast<Application*>(QCoreApplication::instance()); } static Application* getInstance() { return static_cast<Application*>(QCoreApplication::instance()); }
static QString& resourcesPath();
static const glm::vec3& getPositionForPath() { return getInstance()->_myAvatar->getPosition(); } static const glm::vec3& getPositionForPath() { return getInstance()->_myAvatar->getPosition(); }
static glm::quat getOrientationForPath() { return getInstance()->_myAvatar->getOrientation(); } static glm::quat getOrientationForPath() { return getInstance()->_myAvatar->getOrientation(); }
@ -233,7 +232,7 @@ public:
const glm::vec3& getViewMatrixTranslation() const { return _viewMatrixTranslation; } const glm::vec3& getViewMatrixTranslation() const { return _viewMatrixTranslation; }
void setViewMatrixTranslation(const glm::vec3& translation) { _viewMatrixTranslation = translation; } void setViewMatrixTranslation(const glm::vec3& translation) { _viewMatrixTranslation = translation; }
const Transform& getViewTransform() const { return _viewTransform; } virtual const Transform& getViewTransform() const { return _viewTransform; }
void setViewTransform(const Transform& view); void setViewTransform(const Transform& view);
/// if you need to access the application settings, use lockSettings()/unlockSettings() /// if you need to access the application settings, use lockSettings()/unlockSettings()
@ -249,9 +248,6 @@ public:
ToolWindow* getToolWindow() { return _toolWindow ; } ToolWindow* getToolWindow() { return _toolWindow ; }
AnimationCache* getAnimationCache() { return &_animationCache; }
DeferredLightingEffect* getDeferredLightingEffect() { return &_deferredLightingEffect; }
GlowEffect* getGlowEffect() { return &_glowEffect; }
ControllerScriptingInterface* getControllerScriptingInterface() { return &_controllerScriptingInterface; } ControllerScriptingInterface* getControllerScriptingInterface() { return &_controllerScriptingInterface; }
AvatarManager& getAvatarManager() { return _avatarManager; } AvatarManager& getAvatarManager() { return _avatarManager; }
@ -259,7 +255,8 @@ public:
void controlledBroadcastToNodes(const QByteArray& packet, const NodeSet& destinationNodeTypes); void controlledBroadcastToNodes(const QByteArray& packet, const NodeSet& destinationNodeTypes);
void setupWorldLight(); virtual void setupWorldLight();
virtual bool shouldRenderMesh(float largestDimension, float distanceToCamera);
QImage renderAvatarBillboard(); QImage renderAvatarBillboard();
@ -278,12 +275,17 @@ public:
void getModelViewMatrix(glm::dmat4* modelViewMatrix); void getModelViewMatrix(glm::dmat4* modelViewMatrix);
void getProjectionMatrix(glm::dmat4* projectionMatrix); void getProjectionMatrix(glm::dmat4* projectionMatrix);
const glm::vec3& getShadowDistances() const { return _shadowDistances; } virtual const glm::vec3& getShadowDistances() const { return _shadowDistances; }
/// Computes the off-axis frustum parameters for the view frustum, taking mirroring into account. /// Computes the off-axis frustum parameters for the view frustum, taking mirroring into account.
void computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal, virtual void computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal,
float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const; float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const;
virtual ViewFrustum* getCurrentViewFrustum() { return getDisplayViewFrustum(); }
virtual bool getShadowsEnabled();
virtual bool getCascadeShadowsEnabled();
virtual QThread* getMainThread() { return thread(); }
NodeBounds& getNodeBoundsDisplay() { return _nodeBoundsDisplay; } NodeBounds& getNodeBoundsDisplay() { return _nodeBoundsDisplay; }
FileLogger* getLogger() { return _logger; } FileLogger* getLogger() { return _logger; }
@ -566,13 +568,6 @@ private:
QSet<int> _keysPressed; QSet<int> _keysPressed;
AnimationCache _animationCache;
DeferredLightingEffect _deferredLightingEffect;
GlowEffect _glowEffect;
AmbientOcclusionEffect _ambientOcclusionEffect;
Audio _audio; Audio _audio;
bool _enableProcessVoxelsThread; bool _enableProcessVoxelsThread;

View file

@ -37,6 +37,7 @@
#include <AudioInjector.h> #include <AudioInjector.h>
#include <NodeList.h> #include <NodeList.h>
#include <PacketHeaders.h> #include <PacketHeaders.h>
#include <PathUtils.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include <StDev.h> #include <StDev.h>
#include <UUID.h> #include <UUID.h>
@ -140,9 +141,9 @@ Audio::Audio(QObject* parent) :
} }
void Audio::init(QGLWidget *parent) { void Audio::init(QGLWidget *parent) {
_micTextureId = parent->bindTexture(QImage(Application::resourcesPath() + "images/mic.svg")); _micTextureId = parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/mic.svg"));
_muteTextureId = parent->bindTexture(QImage(Application::resourcesPath() + "images/mic-mute.svg")); _muteTextureId = parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/mic-mute.svg"));
_boxTextureId = parent->bindTexture(QImage(Application::resourcesPath() + "images/audio-box.svg")); _boxTextureId = parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/audio-box.svg"));
} }
void Audio::reset() { void Audio::reset() {

View file

@ -17,11 +17,12 @@
#include <GeometryUtil.h> #include <GeometryUtil.h>
#include <PacketHeaders.h> #include <PacketHeaders.h>
#include <PathUtils.h>
#include <ProgramObject.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include "Application.h" #include "Application.h"
#include "Camera.h" #include "Camera.h"
#include "renderer/ProgramObject.h"
#include "world.h" #include "world.h"
#include "Environment.h" #include "Environment.h"
@ -188,7 +189,7 @@ int Environment::parseData(const HifiSockAddr& senderAddress, const QByteArray&
ProgramObject* Environment::createSkyProgram(const char* from, int* locations) { ProgramObject* Environment::createSkyProgram(const char* from, int* locations) {
ProgramObject* program = new ProgramObject(); ProgramObject* program = new ProgramObject();
QByteArray prefix = QString(Application::resourcesPath() + "/shaders/SkyFrom" + from).toUtf8(); QByteArray prefix = QString(PathUtils::resourcesPath() + "/shaders/SkyFrom" + from).toUtf8();
program->addShaderFromSourceFile(QGLShader::Vertex, prefix + ".vert"); program->addShaderFromSourceFile(QGLShader::Vertex, prefix + ".vert");
program->addShaderFromSourceFile(QGLShader::Fragment, prefix + ".frag"); program->addShaderFromSourceFile(QGLShader::Fragment, prefix + ".frag");
program->link(); program->link();

View file

@ -32,6 +32,8 @@
#include <AccountManager.h> #include <AccountManager.h>
#include <AddressManager.h> #include <AddressManager.h>
#include <DependencyManager.h> #include <DependencyManager.h>
#include <GlowEffect.h>
#include <PathUtils.h>
#include <UUID.h> #include <UUID.h>
#include <UserActivityLogger.h> #include <UserActivityLogger.h>
#include <XmppClient.h> #include <XmppClient.h>
@ -54,7 +56,6 @@
#include "ui/LoginDialog.h" #include "ui/LoginDialog.h"
#include "ui/NodeBounds.h" #include "ui/NodeBounds.h"
Menu* Menu::_instance = NULL; Menu* Menu::_instance = NULL;
Menu* Menu::getInstance() { Menu* Menu::getInstance() {
@ -246,7 +247,7 @@ Menu::Menu() :
connect(&xmppClient, &QXmppClient::connected, this, &Menu::toggleChat); connect(&xmppClient, &QXmppClient::connected, this, &Menu::toggleChat);
connect(&xmppClient, &QXmppClient::disconnected, this, &Menu::toggleChat); connect(&xmppClient, &QXmppClient::disconnected, this, &Menu::toggleChat);
QDir::setCurrent(Application::resourcesPath()); QDir::setCurrent(PathUtils::resourcesPath());
// init chat window to listen chat // init chat window to listen chat
_chatWindow = new ChatWindow(Application::getInstance()->getWindow()); _chatWindow = new ChatWindow(Application::getInstance()->getWindow());
#endif #endif
@ -424,7 +425,8 @@ Menu::Menu() :
true, true,
appInstance, appInstance,
SLOT(setRenderVoxels(bool))); SLOT(setRenderVoxels(bool)));
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::EnableGlowEffect, 0, true); addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::EnableGlowEffect, 0, true,
DependencyManager::get<GlowEffect>(), SLOT(toggleGlowEffect(bool)));
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Wireframe, Qt::ALT | Qt::Key_W, false); addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Wireframe, Qt::ALT | Qt::Key_W, false);
addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools, Qt::SHIFT | Qt::Key_L, this, SLOT(lodTools())); addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools, Qt::SHIFT | Qt::Key_L, this, SLOT(lodTools()));

View file

@ -361,9 +361,6 @@ namespace MenuOption {
const QString Collisions = "Collisions"; const QString Collisions = "Collisions";
const QString Console = "Console..."; const QString Console = "Console...";
const QString ControlWithSpeech = "Control With Speech"; const QString ControlWithSpeech = "Control With Speech";
const QString DontCullOutOfViewMeshParts = "Don't Cull Out Of View Mesh Parts";
const QString DontCullTooSmallMeshParts = "Don't Cull Too Small Mesh Parts";
const QString DontReduceMaterialSwitches = "Don't Attempt to Reduce Material Switches";
const QString DontRenderEntitiesAsScene = "Don't Render Entities as Scene"; const QString DontRenderEntitiesAsScene = "Don't Render Entities as Scene";
const QString DontDoPrecisionPicking = "Don't Do Precision Picking"; const QString DontDoPrecisionPicking = "Don't Do Precision Picking";
const QString DecreaseAvatarSize = "Decrease Avatar Size"; const QString DecreaseAvatarSize = "Decrease Avatar Size";

View file

@ -21,17 +21,18 @@
#include <glm/gtx/transform.hpp> #include <glm/gtx/transform.hpp>
#include <DeferredLightingEffect.h>
#include <GeometryUtil.h> #include <GeometryUtil.h>
#include <Model.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include <MetavoxelMessages.h> #include <MetavoxelMessages.h>
#include <MetavoxelUtil.h> #include <MetavoxelUtil.h>
#include <PathUtils.h>
#include <ScriptCache.h> #include <ScriptCache.h>
#include "Application.h" #include "Application.h"
#include "MetavoxelSystem.h" #include "MetavoxelSystem.h"
#include "renderer/Model.h"
#include "renderer/RenderUtil.h"
REGISTER_META_OBJECT(DefaultMetavoxelRendererImplementation) REGISTER_META_OBJECT(DefaultMetavoxelRendererImplementation)
REGISTER_META_OBJECT(SphereRenderer) REGISTER_META_OBJECT(SphereRenderer)
@ -63,9 +64,9 @@ void MetavoxelSystem::init() {
_voxelBufferAttribute->setLODThresholdMultiplier( _voxelBufferAttribute->setLODThresholdMultiplier(
AttributeRegistry::getInstance()->getVoxelColorAttribute()->getLODThresholdMultiplier()); AttributeRegistry::getInstance()->getVoxelColorAttribute()->getLODThresholdMultiplier());
_baseHeightfieldProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + _baseHeightfieldProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() +
"shaders/metavoxel_heightfield_base.vert"); "shaders/metavoxel_heightfield_base.vert");
_baseHeightfieldProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + _baseHeightfieldProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() +
"shaders/metavoxel_heightfield_base.frag"); "shaders/metavoxel_heightfield_base.frag");
_baseHeightfieldProgram.link(); _baseHeightfieldProgram.link();
@ -78,9 +79,9 @@ void MetavoxelSystem::init() {
loadSplatProgram("heightfield", _splatHeightfieldProgram, _splatHeightfieldLocations); loadSplatProgram("heightfield", _splatHeightfieldProgram, _splatHeightfieldLocations);
_heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() +
"shaders/metavoxel_heightfield_cursor.vert"); "shaders/metavoxel_heightfield_cursor.vert");
_heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() +
"shaders/metavoxel_cursor.frag"); "shaders/metavoxel_cursor.frag");
_heightfieldCursorProgram.link(); _heightfieldCursorProgram.link();
@ -88,17 +89,17 @@ void MetavoxelSystem::init() {
_heightfieldCursorProgram.setUniformValue("heightMap", 0); _heightfieldCursorProgram.setUniformValue("heightMap", 0);
_heightfieldCursorProgram.release(); _heightfieldCursorProgram.release();
_baseVoxelProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + _baseVoxelProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() +
"shaders/metavoxel_voxel_base.vert"); "shaders/metavoxel_voxel_base.vert");
_baseVoxelProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + _baseVoxelProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() +
"shaders/metavoxel_voxel_base.frag"); "shaders/metavoxel_voxel_base.frag");
_baseVoxelProgram.link(); _baseVoxelProgram.link();
loadSplatProgram("voxel", _splatVoxelProgram, _splatVoxelLocations); loadSplatProgram("voxel", _splatVoxelProgram, _splatVoxelLocations);
_voxelCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + _voxelCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() +
"shaders/metavoxel_voxel_cursor.vert"); "shaders/metavoxel_voxel_cursor.vert");
_voxelCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + _voxelCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() +
"shaders/metavoxel_cursor.frag"); "shaders/metavoxel_cursor.frag");
_voxelCursorProgram.link(); _voxelCursorProgram.link();
} }
@ -470,7 +471,7 @@ void MetavoxelSystem::render() {
glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glNormal3f(0.0f, 1.0f, 0.0f); glNormal3f(0.0f, 1.0f, 0.0f);
Application::getInstance()->getDeferredLightingEffect()->bindSimpleProgram(); DependencyManager::get<DeferredLightingEffect>()->bindSimpleProgram();
foreach (const HermiteBatch& batch, _hermiteBatches) { foreach (const HermiteBatch& batch, _hermiteBatches) {
batch.vertexBuffer->bind(); batch.vertexBuffer->bind();
@ -482,7 +483,7 @@ void MetavoxelSystem::render() {
batch.vertexBuffer->release(); batch.vertexBuffer->release();
} }
Application::getInstance()->getDeferredLightingEffect()->releaseSimpleProgram(); DependencyManager::get<DeferredLightingEffect>()->releaseSimpleProgram();
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
@ -826,9 +827,9 @@ void MetavoxelSystem::guideToAugmented(MetavoxelVisitor& visitor, bool render) {
} }
void MetavoxelSystem::loadSplatProgram(const char* type, ProgramObject& program, SplatLocations& locations) { void MetavoxelSystem::loadSplatProgram(const char* type, ProgramObject& program, SplatLocations& locations) {
program.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + program.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() +
"shaders/metavoxel_" + type + "_splat.vert"); "shaders/metavoxel_" + type + "_splat.vert");
program.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + program.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() +
"shaders/metavoxel_" + type + "_splat.frag"); "shaders/metavoxel_" + type + "_splat.frag");
program.link(); program.link();
@ -1977,7 +1978,7 @@ void SphereRenderer::render(const MetavoxelLOD& lod, bool contained, bool cursor
glm::vec3 axis = glm::axis(rotation); glm::vec3 axis = glm::axis(rotation);
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z); glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
Application::getInstance()->getDeferredLightingEffect()->renderSolidSphere(sphere->getScale(), 32, 32); DependencyManager::get<DeferredLightingEffect>()->renderSolidSphere(sphere->getScale(), 32, 32);
glPopMatrix(); glPopMatrix();
} }
@ -1998,7 +1999,7 @@ void CuboidRenderer::render(const MetavoxelLOD& lod, bool contained, bool cursor
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z); glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
glScalef(1.0f, cuboid->getAspectY(), cuboid->getAspectZ()); glScalef(1.0f, cuboid->getAspectY(), cuboid->getAspectZ());
Application::getInstance()->getDeferredLightingEffect()->renderSolidCube(cuboid->getScale() * 2.0f); DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(cuboid->getScale() * 2.0f);
glPopMatrix(); glPopMatrix();
} }

View file

@ -20,9 +20,8 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <MetavoxelClientManager.h> #include <MetavoxelClientManager.h>
#include <ProgramObject.h>
#include "renderer/ProgramObject.h" #include <TextureCache.h>
#include "renderer/TextureCache.h"
class HeightfieldBaseLayerBatch; class HeightfieldBaseLayerBatch;
class HeightfieldSplatBatch; class HeightfieldSplatBatch;

View file

@ -11,6 +11,8 @@
#include <vector> #include <vector>
#include <gpu/GPUConfig.h>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QWindow> #include <QWindow>
@ -20,11 +22,15 @@
#include <glm/gtc/type_ptr.hpp> #include <glm/gtc/type_ptr.hpp>
#include <glm/gtx/vector_query.hpp> #include <glm/gtx/vector_query.hpp>
#include <DeferredLightingEffect.h>
#include <GeometryUtil.h> #include <GeometryUtil.h>
#include <GlowEffect.h>
#include <NodeList.h> #include <NodeList.h>
#include <PacketHeaders.h> #include <PacketHeaders.h>
#include <PathUtils.h>
#include <PerfStat.h> #include <PerfStat.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include <TextureCache.h>
#include "Application.h" #include "Application.h"
#include "Avatar.h" #include "Avatar.h"
@ -36,7 +42,6 @@
#include "Recorder.h" #include "Recorder.h"
#include "world.h" #include "world.h"
#include "devices/OculusManager.h" #include "devices/OculusManager.h"
#include "renderer/TextureCache.h"
#include "ui/TextRenderer.h" #include "ui/TextRenderer.h"
using namespace std; using namespace std;
@ -360,7 +365,7 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode, bool
glm::quat orientation = getOrientation(); glm::quat orientation = getOrientation();
foreach (const AvatarManager::LocalLight& light, Application::getInstance()->getAvatarManager().getLocalLights()) { foreach (const AvatarManager::LocalLight& light, Application::getInstance()->getAvatarManager().getLocalLights()) {
glm::vec3 direction = orientation * light.direction; glm::vec3 direction = orientation * light.direction;
Application::getInstance()->getDeferredLightingEffect()->addSpotLight(position - direction * distance, DependencyManager::get<DeferredLightingEffect>()->addSpotLight(position - direction * distance,
distance * 2.0f, glm::vec3(), light.color, light.color, 1.0f, 0.5f, 0.0f, direction, distance * 2.0f, glm::vec3(), light.color, light.color, 1.0f, 0.5f, 0.0f, direction,
LIGHT_EXPONENT, LIGHT_CUTOFF); LIGHT_EXPONENT, LIGHT_CUTOFF);
} }
@ -913,13 +918,13 @@ void Avatar::scaleVectorRelativeToPosition(glm::vec3 &positionToScale) const {
void Avatar::setFaceModelURL(const QUrl& faceModelURL) { void Avatar::setFaceModelURL(const QUrl& faceModelURL) {
AvatarData::setFaceModelURL(faceModelURL); AvatarData::setFaceModelURL(faceModelURL);
const QUrl DEFAULT_FACE_MODEL_URL = QUrl::fromLocalFile(Application::resourcesPath() + "meshes/defaultAvatar_head.fst"); const QUrl DEFAULT_FACE_MODEL_URL = QUrl::fromLocalFile(PathUtils::resourcesPath() + "meshes/defaultAvatar_head.fst");
getHead()->getFaceModel().setURL(_faceModelURL, DEFAULT_FACE_MODEL_URL, true, !isMyAvatar()); getHead()->getFaceModel().setURL(_faceModelURL, DEFAULT_FACE_MODEL_URL, true, !isMyAvatar());
} }
void Avatar::setSkeletonModelURL(const QUrl& skeletonModelURL) { void Avatar::setSkeletonModelURL(const QUrl& skeletonModelURL) {
AvatarData::setSkeletonModelURL(skeletonModelURL); AvatarData::setSkeletonModelURL(skeletonModelURL);
const QUrl DEFAULT_SKELETON_MODEL_URL = QUrl::fromLocalFile(Application::resourcesPath() + "meshes/defaultAvatar_body.fst"); const QUrl DEFAULT_SKELETON_MODEL_URL = QUrl::fromLocalFile(PathUtils::resourcesPath() + "meshes/defaultAvatar_body.fst");
_skeletonModel.setURL(_skeletonModelURL, DEFAULT_SKELETON_MODEL_URL, true, !isMyAvatar()); _skeletonModel.setURL(_skeletonModelURL, DEFAULT_SKELETON_MODEL_URL, true, !isMyAvatar());
} }

View file

@ -15,16 +15,17 @@
#include <glm/gtx/string_cast.hpp> #include <glm/gtx/string_cast.hpp>
#include <GlowEffect.h>
#include <PerfStat.h> #include <PerfStat.h>
#include <RegisteredMetaTypes.h> #include <RegisteredMetaTypes.h>
#include <UUID.h> #include <UUID.h>
#include "Application.h" #include "Application.h"
#include "Avatar.h" #include "Avatar.h"
#include "AvatarManager.h"
#include "Menu.h" #include "Menu.h"
#include "MyAvatar.h" #include "MyAvatar.h"
#include "AvatarManager.h"
// We add _myAvatar into the hash with all the other AvatarData, and we use the default NULL QUid as the key. // We add _myAvatar into the hash with all the other AvatarData, and we use the default NULL QUid as the key.
const QUuid MY_AVATAR_KEY; // NULL key const QUuid MY_AVATAR_KEY; // NULL key

View file

@ -12,7 +12,7 @@
#ifndef hifi_FaceModel_h #ifndef hifi_FaceModel_h
#define hifi_FaceModel_h #define hifi_FaceModel_h
#include "renderer/Model.h" #include <Model.h>
class Head; class Head;

View file

@ -8,18 +8,20 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include <gpu/GPUConfig.h> // hack to get windows to build
#include <QImage> #include <QImage>
#include <NodeList.h> #include <NodeList.h>
#include <GeometryUtil.h> #include <GeometryUtil.h>
#include <ProgramObject.h>
#include "Application.h" #include "Application.h"
#include "Avatar.h" #include "Avatar.h"
#include "Hand.h" #include "Hand.h"
#include "Menu.h" #include "Menu.h"
#include "Util.h" #include "Util.h"
#include "renderer/ProgramObject.h"
using namespace std; using namespace std;

View file

@ -11,6 +11,8 @@
#ifndef hifi_Hand_h #ifndef hifi_Hand_h
#define hifi_Hand_h #define hifi_Hand_h
#include "InterfaceConfig.h"
#include <vector> #include <vector>
#include <QAction> #include <QAction>
@ -22,9 +24,8 @@
#include <AvatarData.h> #include <AvatarData.h>
#include <AudioScriptingInterface.h> #include <AudioScriptingInterface.h>
#include <HandData.h> #include <HandData.h>
#include <Model.h>
#include "InterfaceConfig.h"
#include "renderer/Model.h"
#include "world.h" #include "world.h"

View file

@ -11,8 +11,7 @@
#include <glm/gtx/quaternion.hpp> #include <glm/gtx/quaternion.hpp>
#include <DependencyManager.h> #include <DependencyManager.h>
#include <devices/Faceshift.h> #include <GlowEffect.h>
#include <devices/DdeFaceTracker.h>
#include <NodeList.h> #include <NodeList.h>
#include "Application.h" #include "Application.h"
@ -21,6 +20,8 @@
#include "Head.h" #include "Head.h"
#include "Menu.h" #include "Menu.h"
#include "Util.h" #include "Util.h"
#include "devices/DdeFaceTracker.h"
#include "devices/Faceshift.h"
#include "devices/OculusManager.h" #include "devices/OculusManager.h"
using namespace std; using namespace std;
@ -331,7 +332,7 @@ void Head::addLeanDeltas(float sideways, float forward) {
void Head::renderLookatVectors(glm::vec3 leftEyePosition, glm::vec3 rightEyePosition, glm::vec3 lookatPosition) { void Head::renderLookatVectors(glm::vec3 leftEyePosition, glm::vec3 rightEyePosition, glm::vec3 lookatPosition) {
Application::getInstance()->getGlowEffect()->begin(); DependencyManager::get<GlowEffect>()->begin();
glLineWidth(2.0); glLineWidth(2.0);
glBegin(GL_LINES); glBegin(GL_LINES);
@ -345,7 +346,7 @@ void Head::renderLookatVectors(glm::vec3 leftEyePosition, glm::vec3 rightEyePosi
glVertex3f(lookatPosition.x, lookatPosition.y, lookatPosition.z); glVertex3f(lookatPosition.x, lookatPosition.y, lookatPosition.z);
glEnd(); glEnd();
Application::getInstance()->getGlowEffect()->end(); DependencyManager::get<GlowEffect>()->end();
} }

View file

@ -10,9 +10,8 @@
// //
#include <AvatarData.h> #include <AvatarData.h>
#include <EntityTree.h> #include <EntityTree.h>
#include "../renderer/Model.h" #include <Model.h>
#include "ModelReferential.h" #include "ModelReferential.h"

View file

@ -22,6 +22,7 @@
#include <AccountManager.h> #include <AccountManager.h>
#include <AddressManager.h> #include <AddressManager.h>
#include <AnimationHandle.h>
#include <DependencyManager.h> #include <DependencyManager.h>
#include <GeometryUtil.h> #include <GeometryUtil.h>
#include <NodeList.h> #include <NodeList.h>
@ -40,7 +41,6 @@
#include "Recorder.h" #include "Recorder.h"
#include "devices/Faceshift.h" #include "devices/Faceshift.h"
#include "devices/OculusManager.h" #include "devices/OculusManager.h"
#include "renderer/AnimationHandle.h"
#include "ui/TextRenderer.h" #include "ui/TextRenderer.h"
using namespace std; using namespace std;

View file

@ -12,9 +12,10 @@
#ifndef hifi_SkeletonModel_h #ifndef hifi_SkeletonModel_h
#define hifi_SkeletonModel_h #define hifi_SkeletonModel_h
#include "renderer/Model.h"
#include <CapsuleShape.h> #include <CapsuleShape.h>
#include <Model.h>
#include "SkeletonRagdoll.h" #include "SkeletonRagdoll.h"
class Avatar; class Avatar;

View file

@ -11,10 +11,10 @@
#include <DistanceConstraint.h> #include <DistanceConstraint.h>
#include <FixedConstraint.h> #include <FixedConstraint.h>
#include <Model.h>
#include "SkeletonRagdoll.h" #include "SkeletonRagdoll.h"
#include "MuscleConstraint.h" #include "MuscleConstraint.h"
#include "../renderer/Model.h"
SkeletonRagdoll::SkeletonRagdoll(Model* model) : Ragdoll(), _model(model) { SkeletonRagdoll::SkeletonRagdoll(Model* model) : Ragdoll(), _model(model) {
assert(_model); assert(_model);

View file

@ -14,10 +14,9 @@
#include <QVector> #include <QVector>
#include <JointState.h>
#include <Ragdoll.h> #include <Ragdoll.h>
#include "../renderer/JointState.h"
class MuscleConstraint; class MuscleConstraint;
class Model; class Model;

View file

@ -21,6 +21,8 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <GlowEffect.h>
#include <PathUtils.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include <UserActivityLogger.h> #include <UserActivityLogger.h>
@ -136,8 +138,8 @@ void OculusManager::connect() {
if (!_programInitialized) { if (!_programInitialized) {
// Shader program // Shader program
_programInitialized = true; _programInitialized = true;
_program.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + "shaders/oculus.vert"); _program.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/oculus.vert");
_program.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/oculus.frag"); _program.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/oculus.frag");
_program.link(); _program.link();
// Uniforms // Uniforms
@ -447,7 +449,7 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p
//Bind our framebuffer object. If we are rendering the glow effect, we let the glow effect shader take care of it //Bind our framebuffer object. If we are rendering the glow effect, we let the glow effect shader take care of it
if (Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect)) { if (Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect)) {
Application::getInstance()->getGlowEffect()->prepare(); DependencyManager::get<GlowEffect>()->prepare();
} else { } else {
DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind(); DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@ -552,7 +554,7 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p
//Bind the output texture from the glow shader. If glow effect is disabled, we just grab the texture //Bind the output texture from the glow shader. If glow effect is disabled, we just grab the texture
if (Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect)) { if (Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect)) {
QOpenGLFramebufferObject* fbo = Application::getInstance()->getGlowEffect()->render(true); QOpenGLFramebufferObject* fbo = DependencyManager::get<GlowEffect>()->render(true);
glBindTexture(GL_TEXTURE_2D, fbo->texture()); glBindTexture(GL_TEXTURE_2D, fbo->texture());
} else { } else {
DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->release(); DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->release();

View file

@ -17,7 +17,8 @@
#include <OVR.h> #include <OVR.h>
#endif #endif
#include "renderer/ProgramObject.h" #include <ProgramObject.h>
#include "ui/overlays/Text3DOverlay.h" #include "ui/overlays/Text3DOverlay.h"
const float DEFAULT_OCULUS_UI_ANGULAR_SIZE = 72.0f; const float DEFAULT_OCULUS_UI_ANGULAR_SIZE = 72.0f;

View file

@ -15,6 +15,8 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <GlowEffect.h>
#include "Application.h" #include "Application.h"
#include "TV3DManager.h" #include "TV3DManager.h"
@ -103,7 +105,7 @@ void TV3DManager::display(Camera& whichCamera) {
applicationOverlay.renderOverlay(true); applicationOverlay.renderOverlay(true);
const bool displayOverlays = Menu::getInstance()->isOptionChecked(MenuOption::UserInterface); const bool displayOverlays = Menu::getInstance()->isOptionChecked(MenuOption::UserInterface);
Application::getInstance()->getGlowEffect()->prepare(); DependencyManager::get<GlowEffect>()->prepare();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@ -169,7 +171,7 @@ void TV3DManager::display(Camera& whichCamera) {
// reset the viewport to how we started // reset the viewport to how we started
glViewport(0, 0, deviceSize.width(), deviceSize.height()); glViewport(0, 0, deviceSize.width(), deviceSize.height());
Application::getInstance()->getGlowEffect()->render(); DependencyManager::get<GlowEffect>()->render();
} }
void TV3DManager::overrideOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal, void TV3DManager::overrideOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal,

View file

@ -14,6 +14,7 @@
#include <DependencyManager.h> #include <DependencyManager.h>
#include <FBXReader.h> #include <FBXReader.h>
#include <PathUtils.h>
#include <PerfStat.h> #include <PerfStat.h>
#include <SharedUtil.h> #include <SharedUtil.h>
@ -45,12 +46,12 @@ Visage::Visage() :
#ifdef HAVE_VISAGE #ifdef HAVE_VISAGE
#ifdef WIN32 #ifdef WIN32
QByteArray licensePath = Application::resourcesPath().toLatin1() + "visage"; QByteArray licensePath = PathUtils::resourcesPath().toLatin1() + "visage";
#else #else
QByteArray licensePath = Application::resourcesPath().toLatin1() + "visage/license.vlc"; QByteArray licensePath = PathUtils::resourcesPath().toLatin1() + "visage/license.vlc";
#endif #endif
initializeLicenseManager(licensePath.data()); initializeLicenseManager(licensePath.data());
_tracker = new VisageTracker2(Application::resourcesPath().toLatin1() + "visage/tracker.cfg"); _tracker = new VisageTracker2(PathUtils::resourcesPath().toLatin1() + "visage/tracker.cfg");
_data = new FaceData(); _data = new FaceData();
#endif #endif
} }

View file

@ -18,6 +18,7 @@
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include <BoxEntityItem.h> #include <BoxEntityItem.h>
#include <GlowEffect.h>
#include <ModelEntityItem.h> #include <ModelEntityItem.h>
#include <MouseEvent.h> #include <MouseEvent.h>
#include <PerfStat.h> #include <PerfStat.h>
@ -41,8 +42,6 @@ QThread* EntityTreeRenderer::getMainThread() {
return Application::getInstance()->getEntities()->thread(); return Application::getInstance()->getEntities()->thread();
} }
EntityTreeRenderer::EntityTreeRenderer(bool wantScripts) : EntityTreeRenderer::EntityTreeRenderer(bool wantScripts) :
OctreeRenderer(), OctreeRenderer(),
_wantScripts(wantScripts), _wantScripts(wantScripts),

View file

@ -17,6 +17,7 @@
#include <EntityTree.h> #include <EntityTree.h>
#include <EntityScriptingInterface.h> // for RayToEntityIntersectionResult #include <EntityScriptingInterface.h> // for RayToEntityIntersectionResult
#include <Model.h>
#include <Octree.h> #include <Octree.h>
#include <OctreePacketData.h> #include <OctreePacketData.h>
#include <OctreeRenderer.h> #include <OctreeRenderer.h>
@ -25,7 +26,6 @@
#include <SharedUtil.h> #include <SharedUtil.h>
#include <ViewFrustum.h> #include <ViewFrustum.h>
#include "renderer/Model.h"
class EntityScriptDetails { class EntityScriptDetails {
public: public:

View file

@ -16,6 +16,7 @@
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include <BoxEntityItem.h> #include <BoxEntityItem.h>
#include <DeferredLightingEffect.h>
#include <ModelEntityItem.h> #include <ModelEntityItem.h>
#include <PerfStat.h> #include <PerfStat.h>
@ -53,7 +54,7 @@ void RenderableBoxEntityItem::render(RenderArgs* args) {
glm::vec3 positionToCenter = center - position; glm::vec3 positionToCenter = center - position;
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z); glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
glScalef(dimensions.x, dimensions.y, dimensions.z); glScalef(dimensions.x, dimensions.y, dimensions.z);
Application::getInstance()->getDeferredLightingEffect()->renderSolidCube(1.0f); DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f);
glPopMatrix(); glPopMatrix();
glPopMatrix(); glPopMatrix();
} else { } else {
@ -90,7 +91,7 @@ void RenderableBoxEntityItem::render(RenderArgs* args) {
glColor4f(getColor()[RED_INDEX] / MAX_COLOR, getColor()[GREEN_INDEX] / MAX_COLOR, glColor4f(getColor()[RED_INDEX] / MAX_COLOR, getColor()[GREEN_INDEX] / MAX_COLOR,
getColor()[BLUE_INDEX] / MAX_COLOR, getLocalRenderAlpha()); getColor()[BLUE_INDEX] / MAX_COLOR, getLocalRenderAlpha());
Application::getInstance()->getDeferredLightingEffect()->bindSimpleProgram(); DependencyManager::get<DeferredLightingEffect>()->bindSimpleProgram();
glPushMatrix(); glPushMatrix();
glTranslatef(position.x, position.y, position.z); glTranslatef(position.x, position.y, position.z);
@ -105,7 +106,7 @@ void RenderableBoxEntityItem::render(RenderArgs* args) {
glPopMatrix(); glPopMatrix();
glPopMatrix(); glPopMatrix();
Application::getInstance()->getDeferredLightingEffect()->releaseSimpleProgram(); DependencyManager::get<DeferredLightingEffect>()->releaseSimpleProgram();
glDisableClientState(GL_VERTEX_ARRAY); // disable vertex arrays glDisableClientState(GL_VERTEX_ARRAY); // disable vertex arrays
glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_NORMAL_ARRAY);

View file

@ -15,6 +15,7 @@
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include <DeferredLightingEffect.h>
#include <PerfStat.h> #include <PerfStat.h>
#include <LightEntityItem.h> #include <LightEntityItem.h>
@ -33,7 +34,6 @@ void RenderableLightEntityItem::render(RenderArgs* args) {
PerformanceTimer perfTimer("RenderableLightEntityItem::render"); PerformanceTimer perfTimer("RenderableLightEntityItem::render");
assert(getType() == EntityTypes::Light); assert(getType() == EntityTypes::Light);
glm::vec3 position = getPositionInMeters(); glm::vec3 position = getPositionInMeters();
glm::vec3 center = getCenterInMeters();
glm::vec3 dimensions = getDimensions() * (float)TREE_SCALE; glm::vec3 dimensions = getDimensions() * (float)TREE_SCALE;
glm::quat rotation = getRotation(); glm::quat rotation = getRotation();
float largestDiameter = glm::max(dimensions.x, dimensions.y, dimensions.z); float largestDiameter = glm::max(dimensions.x, dimensions.y, dimensions.z);
@ -65,30 +65,30 @@ void RenderableLightEntityItem::render(RenderArgs* args) {
if (!disableLights) { if (!disableLights) {
if (_isSpotlight) { if (_isSpotlight) {
Application::getInstance()->getDeferredLightingEffect()->addSpotLight(position, largestDiameter / 2.0f, DependencyManager::get<DeferredLightingEffect>()->addSpotLight(position, largestDiameter / 2.0f,
ambient, diffuse, specular, constantAttenuation, linearAttenuation, quadraticAttenuation, ambient, diffuse, specular, constantAttenuation, linearAttenuation, quadraticAttenuation,
direction, exponent, cutoff); direction, exponent, cutoff);
} else { } else {
Application::getInstance()->getDeferredLightingEffect()->addPointLight(position, largestDiameter / 2.0f, DependencyManager::get<DeferredLightingEffect>()->addPointLight(position, largestDiameter / 2.0f,
ambient, diffuse, specular, constantAttenuation, linearAttenuation, quadraticAttenuation); ambient, diffuse, specular, constantAttenuation, linearAttenuation, quadraticAttenuation);
} }
} }
bool wantDebug = false;
if (wantDebug) {
glColor4f(diffuseR, diffuseG, diffuseB, 1.0f);
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
glm::vec3 axis = glm::axis(rotation);
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
glPushMatrix();
glm::vec3 positionToCenter = center - position;
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
glScalef(dimensions.x, dimensions.y, dimensions.z); #ifdef WANT_DEBUG
Application::getInstance()->getDeferredLightingEffect()->renderWireSphere(0.5f, 15, 15); glColor4f(diffuseR, diffuseG, diffuseB, 1.0f);
glPopMatrix(); glPushMatrix();
glTranslatef(position.x, position.y, position.z);
glm::vec3 axis = glm::axis(rotation);
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
glPushMatrix();
glm::vec3 positionToCenter = center - position;
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
glScalef(dimensions.x, dimensions.y, dimensions.z);
DependencyManager::get<DeferredLightingEffect>()->renderWireSphere(0.5f, 15, 15);
glPopMatrix(); glPopMatrix();
} glPopMatrix();
#endif
}; };
bool RenderableLightEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction, bool RenderableLightEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,

View file

@ -16,6 +16,7 @@
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include <BoxEntityItem.h> #include <BoxEntityItem.h>
#include <DeferredLightingEffect.h>
#include <ModelEntityItem.h> #include <ModelEntityItem.h>
#include <PerfStat.h> #include <PerfStat.h>
@ -191,7 +192,7 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
glColor3ub(getColor()[RED_INDEX],getColor()[GREEN_INDEX],getColor()[BLUE_INDEX]); glColor3ub(getColor()[RED_INDEX],getColor()[GREEN_INDEX],getColor()[BLUE_INDEX]);
glPushMatrix(); glPushMatrix();
glTranslatef(position.x, position.y, position.z); glTranslatef(position.x, position.y, position.z);
Application::getInstance()->getDeferredLightingEffect()->renderWireCube(size); DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size);
glPopMatrix(); glPopMatrix();
} }
} else { } else {
@ -199,7 +200,7 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
glColor3ub(getColor()[RED_INDEX],getColor()[GREEN_INDEX],getColor()[BLUE_INDEX]); glColor3ub(getColor()[RED_INDEX],getColor()[GREEN_INDEX],getColor()[BLUE_INDEX]);
glPushMatrix(); glPushMatrix();
glTranslatef(position.x, position.y, position.z); glTranslatef(position.x, position.y, position.z);
Application::getInstance()->getDeferredLightingEffect()->renderWireCube(size); DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size);
glPopMatrix(); glPopMatrix();
} }
} }
@ -208,7 +209,7 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
glColor3ub(getColor()[RED_INDEX],getColor()[GREEN_INDEX],getColor()[BLUE_INDEX]); glColor3ub(getColor()[RED_INDEX],getColor()[GREEN_INDEX],getColor()[BLUE_INDEX]);
glPushMatrix(); glPushMatrix();
glTranslatef(position.x, position.y, position.z); glTranslatef(position.x, position.y, position.z);
Application::getInstance()->getDeferredLightingEffect()->renderWireCube(size); DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size);
glPopMatrix(); glPopMatrix();
} }
} }

View file

@ -16,6 +16,8 @@
#include <stdint.h> #include <stdint.h>
#include <EntityTree.h> #include <EntityTree.h>
#include <Model.h>
#include <ModelEntityItem.h>
#include <Octree.h> #include <Octree.h>
#include <OctreePacketData.h> #include <OctreePacketData.h>
#include <OctreeRenderer.h> #include <OctreeRenderer.h>
@ -23,11 +25,6 @@
#include <SharedUtil.h> #include <SharedUtil.h>
#include <ViewFrustum.h> #include <ViewFrustum.h>
#include "renderer/Model.h"
#include <ModelEntityItem.h>
#include <BoxEntityItem.h>
class RenderableModelEntityItem : public ModelEntityItem { class RenderableModelEntityItem : public ModelEntityItem {
public: public:
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties); static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);

View file

@ -15,6 +15,8 @@
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include <DependencyManager.h>
#include <DeferredLightingEffect.h>
#include <PerfStat.h> #include <PerfStat.h>
#include <SphereEntityItem.h> #include <SphereEntityItem.h>
@ -23,7 +25,6 @@
#include "EntityTreeRenderer.h" #include "EntityTreeRenderer.h"
#include "RenderableSphereEntityItem.h" #include "RenderableSphereEntityItem.h"
EntityItem* RenderableSphereEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { EntityItem* RenderableSphereEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return new RenderableSphereEntityItem(entityID, properties); return new RenderableSphereEntityItem(entityID, properties);
} }
@ -51,7 +52,7 @@ void RenderableSphereEntityItem::render(RenderArgs* args) {
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z); glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
glScalef(dimensions.x, dimensions.y, dimensions.z); glScalef(dimensions.x, dimensions.y, dimensions.z);
Application::getInstance()->getDeferredLightingEffect()->renderSolidSphere(0.5f, 15, 15); DependencyManager::get<DeferredLightingEffect>()->renderSolidSphere(0.5f, 15, 15);
glPopMatrix(); glPopMatrix();
glPopMatrix(); glPopMatrix();
}; };

View file

@ -200,7 +200,7 @@ void WindowScriptingInterface::showNonBlockingForm(const QString& title, QScript
} }
// what should we do if someone calls us while we still think we have a dialog showing??? // what should we do if someone calls us while we still think we have a dialog showing???
if (_editDialog) { if (_nonBlockingFormActive) {
qDebug() << "Show Non-Blocking Form called when form already active."; qDebug() << "Show Non-Blocking Form called when form already active.";
return; return;
} }

View file

@ -13,7 +13,6 @@
#define hifi_Config_h #define hifi_Config_h
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include "renderer/ProgramObject.h"
#include <cstddef> #include <cstddef>
#include <cfloat> #include <cfloat>
@ -35,6 +34,8 @@
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/matrix_access.hpp> #include <glm/gtc/matrix_access.hpp>
#include <ProgramObject.h>
#include "AngleUtil.h" #include "AngleUtil.h"
#include "Radix2InplaceSort.h" #include "Radix2InplaceSort.h"
#include "Radix2IntegerScanner.h" #include "Radix2IntegerScanner.h"

View file

@ -9,6 +9,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include <PathUtils.h>
#include "AddressBarDialog.h" #include "AddressBarDialog.h"
#include "AddressManager.h" #include "AddressManager.h"
#include "Application.h" #include "Application.h"
@ -82,7 +84,7 @@ void AddressBarDialog::setupUI() {
_goButton->setSizePolicy(sizePolicy); _goButton->setSizePolicy(sizePolicy);
_goButton->setMinimumSize(QSize(GO_BUTTON_SIZE, GO_BUTTON_SIZE)); _goButton->setMinimumSize(QSize(GO_BUTTON_SIZE, GO_BUTTON_SIZE));
_goButton->setMaximumSize(QSize(GO_BUTTON_SIZE, GO_BUTTON_SIZE)); _goButton->setMaximumSize(QSize(GO_BUTTON_SIZE, GO_BUTTON_SIZE));
_goButton->setIcon(QIcon(Application::resourcesPath() + ADDRESSBAR_GO_BUTTON_ICON)); _goButton->setIcon(QIcon(PathUtils::resourcesPath() + ADDRESSBAR_GO_BUTTON_ICON));
_goButton->setIconSize(QSize(GO_BUTTON_SIZE, GO_BUTTON_SIZE)); _goButton->setIconSize(QSize(GO_BUTTON_SIZE, GO_BUTTON_SIZE));
_goButton->setDefault(true); _goButton->setDefault(true);
_goButton->setFlat(true); _goButton->setFlat(true);
@ -99,7 +101,7 @@ void AddressBarDialog::setupUI() {
_closeButton->setSizePolicy(sizePolicy); _closeButton->setSizePolicy(sizePolicy);
_closeButton->setMinimumSize(QSize(CLOSE_BUTTON_SIZE, CLOSE_BUTTON_SIZE)); _closeButton->setMinimumSize(QSize(CLOSE_BUTTON_SIZE, CLOSE_BUTTON_SIZE));
_closeButton->setMaximumSize(QSize(CLOSE_BUTTON_SIZE, CLOSE_BUTTON_SIZE)); _closeButton->setMaximumSize(QSize(CLOSE_BUTTON_SIZE, CLOSE_BUTTON_SIZE));
QIcon icon(Application::resourcesPath() + CLOSE_BUTTON_ICON); QIcon icon(PathUtils::resourcesPath() + CLOSE_BUTTON_ICON);
_closeButton->setIcon(icon); _closeButton->setIcon(icon);
_closeButton->setIconSize(QSize(CLOSE_BUTTON_SIZE, CLOSE_BUTTON_SIZE)); _closeButton->setIconSize(QSize(CLOSE_BUTTON_SIZE, CLOSE_BUTTON_SIZE));
_closeButton->setFlat(true); _closeButton->setFlat(true);
@ -112,7 +114,7 @@ void AddressBarDialog::setupUI() {
} }
void AddressBarDialog::showEvent(QShowEvent* event) { void AddressBarDialog::showEvent(QShowEvent* event) {
_goButton->setIcon(QIcon(Application::resourcesPath() + ADDRESSBAR_GO_BUTTON_ICON)); _goButton->setIcon(QIcon(PathUtils::resourcesPath() + ADDRESSBAR_GO_BUTTON_ICON));
_addressLineEdit->setText(QString()); _addressLineEdit->setText(QString());
_addressLineEdit->setFocus(); _addressLineEdit->setFocus();
FramelessDialog::showEvent(event); FramelessDialog::showEvent(event);
@ -120,7 +122,7 @@ void AddressBarDialog::showEvent(QShowEvent* event) {
void AddressBarDialog::accept() { void AddressBarDialog::accept() {
if (!_addressLineEdit->text().isEmpty()) { if (!_addressLineEdit->text().isEmpty()) {
_goButton->setIcon(QIcon(Application::resourcesPath() + ADDRESSBAR_GO_BUTTON_ACTIVE_ICON)); _goButton->setIcon(QIcon(PathUtils::resourcesPath() + ADDRESSBAR_GO_BUTTON_ACTIVE_ICON));
AddressManager& addressManager = AddressManager::getInstance(); AddressManager& addressManager = AddressManager::getInstance();
connect(&addressManager, &AddressManager::lookupResultsFinished, this, &QDialog::hide); connect(&addressManager, &AddressManager::lookupResultsFinished, this, &QDialog::hide);
addressManager.handleLookupString(_addressLineEdit->text()); addressManager.handleLookupString(_addressLineEdit->text());

View file

@ -12,6 +12,8 @@
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include <QOpenGLFramebufferObject> #include <QOpenGLFramebufferObject>
#include <PathUtils.h>
#include <PerfStat.h> #include <PerfStat.h>
#include "Application.h" #include "Application.h"
@ -379,7 +381,7 @@ void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float as
glEnd(); glEnd();
if (_crosshairTexture == 0) { if (_crosshairTexture == 0) {
_crosshairTexture = Application::getInstance()->getGLWidget()->bindTexture(QImage(Application::resourcesPath() + "images/sixense-reticle.png")); _crosshairTexture = Application::getInstance()->getGLWidget()->bindTexture(QImage(PathUtils::resourcesPath() + "images/sixense-reticle.png"));
} }
//draw the mouse pointer //draw the mouse pointer
@ -513,7 +515,7 @@ void ApplicationOverlay::renderPointers() {
//lazily load crosshair texture //lazily load crosshair texture
if (_crosshairTexture == 0) { if (_crosshairTexture == 0) {
_crosshairTexture = Application::getInstance()->getGLWidget()->bindTexture(QImage(Application::resourcesPath() + "images/sixense-reticle.png")); _crosshairTexture = Application::getInstance()->getGLWidget()->bindTexture(QImage(PathUtils::resourcesPath() + "images/sixense-reticle.png"));
} }
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);

View file

@ -19,6 +19,7 @@
#include <AddressManager.h> #include <AddressManager.h>
#include <AccountManager.h> #include <AccountManager.h>
#include <PathUtils.h>
#include "Application.h" #include "Application.h"
#include "ChatMessageArea.h" #include "ChatMessageArea.h"
@ -92,9 +93,9 @@ ChatWindow::ChatWindow(QWidget* parent) :
connect(&_trayIcon, SIGNAL(messageClicked()), this, SLOT(notificationClicked())); connect(&_trayIcon, SIGNAL(messageClicked()), this, SLOT(notificationClicked()));
#endif // HAVE_QXMPP #endif // HAVE_QXMPP
QDir mentionSoundsDir(Application::resourcesPath() + mentionSoundsPath); QDir mentionSoundsDir(PathUtils::resourcesPath() + mentionSoundsPath);
_mentionSounds = mentionSoundsDir.entryList(QDir::Files); _mentionSounds = mentionSoundsDir.entryList(QDir::Files);
_trayIcon.setIcon(QIcon( Application::resourcesPath() + "/images/hifi-logo.svg")); _trayIcon.setIcon(QIcon( PathUtils::resourcesPath() + "/images/hifi-logo.svg"));
} }
ChatWindow::~ChatWindow() { ChatWindow::~ChatWindow() {
@ -385,7 +386,7 @@ void ChatWindow::messageReceived(const QXmppMessage& message) {
if (_effectPlayer.state() != QMediaPlayer::PlayingState) { if (_effectPlayer.state() != QMediaPlayer::PlayingState) {
// get random sound // get random sound
QFileInfo inf = QFileInfo(Application::resourcesPath() + QFileInfo inf = QFileInfo(PathUtils::resourcesPath() +
mentionSoundsPath + mentionSoundsPath +
_mentionSounds.at(rand() % _mentionSounds.size())); _mentionSounds.at(rand() % _mentionSounds.size()));
_effectPlayer.setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); _effectPlayer.setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));

View file

@ -12,6 +12,8 @@
#include <QScreen> #include <QScreen>
#include <QWindow> #include <QWindow>
#include <PathUtils.h>
#include "Application.h" #include "Application.h"
#include "FramelessDialog.h" #include "FramelessDialog.h"
#include "Menu.h" #include "Menu.h"
@ -80,10 +82,10 @@ bool FramelessDialog::eventFilter(QObject* sender, QEvent* event) {
} }
void FramelessDialog::setStyleSheetFile(const QString& fileName) { void FramelessDialog::setStyleSheetFile(const QString& fileName) {
QFile globalStyleSheet(Application::resourcesPath() + "styles/global.qss"); QFile globalStyleSheet(PathUtils::resourcesPath() + "styles/global.qss");
QFile styleSheet(Application::resourcesPath() + fileName); QFile styleSheet(PathUtils::resourcesPath() + fileName);
if (styleSheet.open(QIODevice::ReadOnly) && globalStyleSheet.open(QIODevice::ReadOnly) ) { if (styleSheet.open(QIODevice::ReadOnly) && globalStyleSheet.open(QIODevice::ReadOnly) ) {
QDir::setCurrent(Application::resourcesPath()); QDir::setCurrent(PathUtils::resourcesPath());
setStyleSheet(globalStyleSheet.readAll() + styleSheet.readAll()); setStyleSheet(globalStyleSheet.readAll() + styleSheet.readAll());
} }
} }

View file

@ -9,14 +9,17 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include "InfoView.h"
#include <QApplication> #include <QApplication>
#include "Application.h"
#include <QtWebKitWidgets/QWebFrame> #include <QtWebKitWidgets/QWebFrame>
#include <QtWebKit/QWebElement> #include <QtWebKit/QWebElement>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <PathUtils.h>
#include "Application.h"
#include "InfoView.h"
#define SETTINGS_VERSION_KEY "info-version" #define SETTINGS_VERSION_KEY "info-version"
#define MAX_DIALOG_HEIGHT_RATIO 0.9 #define MAX_DIALOG_HEIGHT_RATIO 0.9
@ -25,7 +28,7 @@ InfoView::InfoView(bool forced, QString path) :
{ {
setWindowFlags(Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint); setWindowFlags(Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
QString absPath = QFileInfo(Application::resourcesPath() + path).absoluteFilePath(); QString absPath = QFileInfo(PathUtils::resourcesPath() + path).absoluteFilePath();
QUrl url = QUrl::fromLocalFile(absPath); QUrl url = QUrl::fromLocalFile(absPath);
load(url); load(url);

View file

@ -13,10 +13,11 @@
#include <QLabel> #include <QLabel>
#include <QScrollBar> #include <QScrollBar>
#include "Application.h" #include <PathUtils.h>
#include "ScriptHighlighting.h"
#include "Application.h"
#include "JSConsole.h" #include "JSConsole.h"
#include "ScriptHighlighting.h"
const int NO_CURRENT_HISTORY_COMMAND = -1; const int NO_CURRENT_HISTORY_COMMAND = -1;
const int MAX_HISTORY_SIZE = 64; const int MAX_HISTORY_SIZE = 64;
@ -41,9 +42,9 @@ JSConsole::JSConsole(QWidget* parent, ScriptEngine* scriptEngine) :
_ui->promptTextEdit->setWordWrapMode(QTextOption::NoWrap); _ui->promptTextEdit->setWordWrapMode(QTextOption::NoWrap);
_ui->promptTextEdit->installEventFilter(this); _ui->promptTextEdit->installEventFilter(this);
QFile styleSheet(Application::resourcesPath() + "styles/console.qss"); QFile styleSheet(PathUtils::resourcesPath() + "styles/console.qss");
if (styleSheet.open(QIODevice::ReadOnly)) { if (styleSheet.open(QIODevice::ReadOnly)) {
QDir::setCurrent(Application::resourcesPath()); QDir::setCurrent(PathUtils::resourcesPath());
setStyleSheet(styleSheet.readAll()); setStyleSheet(styleSheet.readAll());
} }

View file

@ -15,10 +15,10 @@
#include <QTextBlock> #include <QTextBlock>
#include <QtGui> #include <QtGui>
#include <PathUtils.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include "Application.h" #include "Application.h"
#include "ui/LogDialog.h" #include "ui/LogDialog.h"
const int TOP_BAR_HEIGHT = 46; const int TOP_BAR_HEIGHT = 46;
@ -44,9 +44,9 @@ LogDialog::LogDialog(QWidget* parent, AbstractLoggerInterface* logger) : QDialog
setWindowTitle("Log"); setWindowTitle("Log");
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
QFile styleSheet(Application::resourcesPath() + "styles/log_dialog.qss"); QFile styleSheet(PathUtils::resourcesPath() + "styles/log_dialog.qss");
if (styleSheet.open(QIODevice::ReadOnly)) { if (styleSheet.open(QIODevice::ReadOnly)) {
QDir::setCurrent(Application::resourcesPath()); QDir::setCurrent(PathUtils::resourcesPath());
setStyleSheet(styleSheet.readAll()); setStyleSheet(styleSheet.readAll());
} }

View file

@ -14,11 +14,12 @@
#include <QPushButton> #include <QPushButton>
#include <QPixmap> #include <QPixmap>
#include <PathUtils.h>
#include "Application.h" #include "Application.h"
#include "Menu.h" #include "Menu.h"
#include "AccountManager.h" #include "AccountManager.h"
#include "ui_loginDialog.h" #include "ui_loginDialog.h"
#include "LoginDialog.h" #include "LoginDialog.h"
const QString FORGOT_PASSWORD_URL = "https://data.highfidelity.io/users/password/new"; const QString FORGOT_PASSWORD_URL = "https://data.highfidelity.io/users/password/new";
@ -30,8 +31,8 @@ LoginDialog::LoginDialog(QWidget* parent) :
_ui->setupUi(this); _ui->setupUi(this);
_ui->errorLabel->hide(); _ui->errorLabel->hide();
_ui->emailLineEdit->setFocus(); _ui->emailLineEdit->setFocus();
_ui->logoLabel->setPixmap(QPixmap(Application::resourcesPath() + "images/hifi-logo.svg")); _ui->logoLabel->setPixmap(QPixmap(PathUtils::resourcesPath() + "images/hifi-logo.svg"));
_ui->loginButton->setIcon(QIcon(Application::resourcesPath() + "images/login.svg")); _ui->loginButton->setIcon(QIcon(PathUtils::resourcesPath() + "images/login.svg"));
_ui->infoLabel->setVisible(false); _ui->infoLabel->setVisible(false);
_ui->errorLabel->setVisible(false); _ui->errorLabel->setVisible(false);

View file

@ -35,6 +35,7 @@
#include <AttributeRegistry.h> #include <AttributeRegistry.h>
#include <MetavoxelMessages.h> #include <MetavoxelMessages.h>
#include <MetavoxelUtil.h> #include <MetavoxelUtil.h>
#include <PathUtils.h>
#include "Application.h" #include "Application.h"
#include "MetavoxelEditor.h" #include "MetavoxelEditor.h"
@ -144,7 +145,7 @@ MetavoxelEditor::MetavoxelEditor() :
return; return;
} }
_gridProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/grid.frag"); _gridProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/grid.frag");
_gridProgram.link(); _gridProgram.link();
} }

View file

@ -15,8 +15,9 @@
#include <QList> #include <QList>
#include <QWidget> #include <QWidget>
#include <ProgramObject.h>
#include "MetavoxelSystem.h" #include "MetavoxelSystem.h"
#include "renderer/ProgramObject.h"
class QColorEditor; class QColorEditor;
class QComboBox; class QComboBox;

View file

@ -13,12 +13,13 @@
#include <QMouseEvent> #include <QMouseEvent>
#include <PathUtils.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include "Application.h" #include "Application.h"
#include "RearMirrorTools.h"
#include "Util.h" #include "Util.h"
#include "RearMirrorTools.h"
const char SETTINGS_GROUP_NAME[] = "Rear View Tools"; const char SETTINGS_GROUP_NAME[] = "Rear View Tools";
const char ZOOM_LEVEL_SETTINGS[] = "ZoomLevel"; const char ZOOM_LEVEL_SETTINGS[] = "ZoomLevel";
@ -32,13 +33,13 @@ RearMirrorTools::RearMirrorTools(QGLWidget* parent, QRect& bounds, QSettings* se
_fullScreen(false) _fullScreen(false)
{ {
_zoomLevel = HEAD; _zoomLevel = HEAD;
_closeTextureId = _parent->bindTexture(QImage(Application::resourcesPath() + "images/close.svg")); _closeTextureId = _parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/close.svg"));
// Disabled for now https://worklist.net/19548 // Disabled for now https://worklist.net/19548
// _resetTextureId = _parent->bindTexture(QImage(Application::resourcesPath() + "images/reset.png")); // _resetTextureId = _parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/reset.png"));
_zoomHeadTextureId = _parent->bindTexture(QImage(Application::resourcesPath() + "images/plus.svg")); _zoomHeadTextureId = _parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/plus.svg"));
_zoomBodyTextureId = _parent->bindTexture(QImage(Application::resourcesPath() + "images/minus.svg")); _zoomBodyTextureId = _parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/minus.svg"));
_shrinkIconRect = QRect(ICON_PADDING, ICON_PADDING, ICON_SIZE, ICON_SIZE); _shrinkIconRect = QRect(ICON_PADDING, ICON_PADDING, ICON_SIZE, ICON_SIZE);
_closeIconRect = QRect(_bounds.left() + ICON_PADDING, _bounds.top() + ICON_PADDING, ICON_SIZE, ICON_SIZE); _closeIconRect = QRect(_bounds.left() + ICON_PADDING, _bounds.top() + ICON_PADDING, ICON_SIZE, ICON_SIZE);

View file

@ -21,6 +21,8 @@
#include <QTableWidgetItem> #include <QTableWidgetItem>
#include <QWindow> #include <QWindow>
#include <PathUtils.h>
#include "Application.h" #include "Application.h"
#include "Menu.h" #include "Menu.h"
#include "ScriptsModel.h" #include "ScriptsModel.h"
@ -109,7 +111,7 @@ void RunningScriptsWidget::setRunningScripts(const QStringList& list) {
QPushButton* closeButton = new QPushButton(row); QPushButton* closeButton = new QPushButton(row);
closeButton->setFlat(true); closeButton->setFlat(true);
closeButton->setIcon( closeButton->setIcon(
QIcon(QPixmap(Application::resourcesPath() + "images/kill-script.svg").scaledToHeight(CLOSE_ICON_HEIGHT))); QIcon(QPixmap(PathUtils::resourcesPath() + "images/kill-script.svg").scaledToHeight(CLOSE_ICON_HEIGHT)));
closeButton->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred)); closeButton->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred));
closeButton->setStyleSheet("border: 0;"); closeButton->setStyleSheet("border: 0;");
closeButton->setCursor(Qt::PointingHandCursor); closeButton->setCursor(Qt::PointingHandCursor);

View file

@ -8,10 +8,12 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include "Application.h" // HACK ATTACK WARNING: for windows build to work, we need this ahead of QtGui #include <gpu/GPUConfig.h>
#include <QtGui> #include <QtGui>
#include "ui_updateDialog.h" #include "ui_updateDialog.h"
#include "Application.h"
#include "UpdateDialog.h" #include "UpdateDialog.h"

View file

@ -18,6 +18,8 @@
#include <QJsonArray> #include <QJsonArray>
#include <QJsonObject> #include <QJsonObject>
#include <PathUtils.h>
#include "Application.h" #include "Application.h"
#include "VoxelImportDialog.h" #include "VoxelImportDialog.h"
@ -64,7 +66,7 @@ QIcon HiFiIconProvider::icon(QFileIconProvider::IconType type) const {
break; break;
} }
return QIcon(Application::resourcesPath() + "icons/" + typeString + ".svg"); return QIcon(PathUtils::resourcesPath() + "icons/" + typeString + ".svg");
} }
QIcon HiFiIconProvider::icon(const QFileInfo &info) const { QIcon HiFiIconProvider::icon(const QFileInfo &info) const {
@ -72,21 +74,21 @@ QIcon HiFiIconProvider::icon(const QFileInfo &info) const {
if (info.isDir()) { if (info.isDir()) {
if (info.absoluteFilePath() == QDir::homePath()) { if (info.absoluteFilePath() == QDir::homePath()) {
return QIcon(Application::resourcesPath() + "icons/home.svg"); return QIcon(PathUtils::resourcesPath() + "icons/home.svg");
} else if (info.absoluteFilePath() == QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)) { } else if (info.absoluteFilePath() == QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)) {
return QIcon(Application::resourcesPath() + "icons/desktop.svg"); return QIcon(PathUtils::resourcesPath() + "icons/desktop.svg");
} else if (info.absoluteFilePath() == QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)) { } else if (info.absoluteFilePath() == QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)) {
return QIcon(Application::resourcesPath() + "icons/documents.svg"); return QIcon(PathUtils::resourcesPath() + "icons/documents.svg");
} }
return QIcon(Application::resourcesPath() + "icons/folder.svg"); return QIcon(PathUtils::resourcesPath() + "icons/folder.svg");
} }
QFileInfo iconFile(Application::resourcesPath() + "icons/" + iconsMap[ext]); QFileInfo iconFile(PathUtils::resourcesPath() + "icons/" + iconsMap[ext]);
if (iconFile.exists() && iconFile.isFile()) { if (iconFile.exists() && iconFile.isFile()) {
return QIcon(iconFile.filePath()); return QIcon(iconFile.filePath());
} }
return QIcon(Application::resourcesPath() + "icons/file.svg"); return QIcon(PathUtils::resourcesPath() + "icons/file.svg");
} }
QString HiFiIconProvider::type(const QFileInfo &info) const { QString HiFiIconProvider::type(const QFileInfo &info) const {
@ -307,16 +309,16 @@ void VoxelImportDialog::setLayout() {
widget = findChild<QWidget*>("treeView"); widget = findChild<QWidget*>("treeView");
widget->setAttribute(Qt::WA_MacShowFocusRect, false); widget->setAttribute(Qt::WA_MacShowFocusRect, false);
QFile styleSheet(Application::resourcesPath() + "styles/import_dialog.qss"); QFile styleSheet(PathUtils::resourcesPath() + "styles/import_dialog.qss");
if (styleSheet.open(QIODevice::ReadOnly)) { if (styleSheet.open(QIODevice::ReadOnly)) {
QDir::setCurrent(Application::resourcesPath()); QDir::setCurrent(PathUtils::resourcesPath());
setStyleSheet(styleSheet.readAll()); setStyleSheet(styleSheet.readAll());
} }
} }
void VoxelImportDialog::setImportTypes() { void VoxelImportDialog::setImportTypes() {
QFile config(Application::resourcesPath() + "config/config.json"); QFile config(PathUtils::resourcesPath() + "config/config.json");
config.open(QFile::ReadOnly | QFile::Text); config.open(QFile::ReadOnly | QFile::Text);
QJsonDocument document = QJsonDocument::fromJson(config.readAll()); QJsonDocument document = QJsonDocument::fromJson(config.readAll());
if (!document.isNull() && !document.isEmpty()) { if (!document.isNull() && !document.isEmpty()) {

View file

@ -15,8 +15,9 @@
#include <QScopedPointer> #include <QScopedPointer>
#include <QUrl> #include <QUrl>
#include <TextureCache.h>
#include "Base3DOverlay.h" #include "Base3DOverlay.h"
#include "renderer/TextureCache.h"
class BillboardOverlay : public Base3DOverlay { class BillboardOverlay : public Base3DOverlay {
Q_OBJECT Q_OBJECT

View file

@ -12,11 +12,11 @@
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include <QGLWidget> #include <QGLWidget>
#include <GlowEffect.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include <StreamUtils.h> #include <StreamUtils.h>
#include "Circle3DOverlay.h" #include "Circle3DOverlay.h"
#include "renderer/GlowEffect.h"
Circle3DOverlay::Circle3DOverlay() : Circle3DOverlay::Circle3DOverlay() :
_startAt(0.0f), _startAt(0.0f),

View file

@ -12,12 +12,14 @@
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include <QGLWidget> #include <QGLWidget>
#include <DeferredLightingEffect.h>
#include <GlowEffect.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include <StreamUtils.h> #include <StreamUtils.h>
#include "Application.h" #include "Application.h"
#include "Cube3DOverlay.h" #include "Cube3DOverlay.h"
#include "renderer/GlowEffect.h"
Cube3DOverlay::Cube3DOverlay() : _borderSize(0) { Cube3DOverlay::Cube3DOverlay() : _borderSize(0) {
} }
@ -74,7 +76,7 @@ void Cube3DOverlay::render(RenderArgs* args) {
glPushMatrix(); glPushMatrix();
glColor4f(1.0f, 1.0f, 1.0f, alpha); glColor4f(1.0f, 1.0f, 1.0f, alpha);
glScalef(dimensions.x * _borderSize, dimensions.y * _borderSize, dimensions.z * _borderSize); glScalef(dimensions.x * _borderSize, dimensions.y * _borderSize, dimensions.z * _borderSize);
Application::getInstance()->getDeferredLightingEffect()->renderSolidCube(1.0f); DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f);
glPopMatrix(); glPopMatrix();
glDepthMask(GL_TRUE); glDepthMask(GL_TRUE);
} }
@ -82,7 +84,7 @@ void Cube3DOverlay::render(RenderArgs* args) {
glPushMatrix(); glPushMatrix();
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha); glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
glScalef(dimensions.x, dimensions.y, dimensions.z); glScalef(dimensions.x, dimensions.y, dimensions.z);
Application::getInstance()->getDeferredLightingEffect()->renderSolidCube(1.0f); DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f);
glPopMatrix(); glPopMatrix();
} else { } else {
glLineWidth(_lineWidth); glLineWidth(_lineWidth);
@ -116,7 +118,7 @@ void Cube3DOverlay::render(RenderArgs* args) {
} else { } else {
glScalef(dimensions.x, dimensions.y, dimensions.z); glScalef(dimensions.x, dimensions.y, dimensions.z);
Application::getInstance()->getDeferredLightingEffect()->renderWireCube(1.0f); DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f);
} }
} }
glPopMatrix(); glPopMatrix();

View file

@ -9,9 +9,10 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include "Grid3DOverlay.h" #include <PathUtils.h>
#include "Application.h" #include "Application.h"
#include "Grid3DOverlay.h"
ProgramObject Grid3DOverlay::_gridProgram; ProgramObject Grid3DOverlay::_gridProgram;
@ -36,7 +37,7 @@ void Grid3DOverlay::render(RenderArgs* args) {
} }
if (!_gridProgram.isLinked()) { if (!_gridProgram.isLinked()) {
if (!_gridProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/grid.frag")) { if (!_gridProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/grid.frag")) {
qDebug() << "Failed to compile: " + _gridProgram.log(); qDebug() << "Failed to compile: " + _gridProgram.log();
return; return;
} }

View file

@ -18,12 +18,12 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <QGLWidget> #include <QGLWidget>
#include <ProgramObject.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include "Base3DOverlay.h" #include "Base3DOverlay.h"
#include "renderer/ProgramObject.h"
class Grid3DOverlay : public Base3DOverlay { class Grid3DOverlay : public Base3DOverlay {
Q_OBJECT Q_OBJECT

View file

@ -11,8 +11,9 @@
// include this before QGLWidget, which includes an earlier version of OpenGL // include this before QGLWidget, which includes an earlier version of OpenGL
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include <GlowEffect.h>
#include "Line3DOverlay.h" #include "Line3DOverlay.h"
#include "renderer/GlowEffect.h"
Line3DOverlay::Line3DOverlay() { Line3DOverlay::Line3DOverlay() {

View file

@ -9,6 +9,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include <GlowEffect.h>
#include "Application.h" #include "Application.h"
#include "LocalModelsOverlay.h" #include "LocalModelsOverlay.h"

View file

@ -15,8 +15,9 @@
#include <QGLWidget> #include <QGLWidget>
#include <QScriptValue> #include <QScriptValue>
#include <Application.h> #include <GlowEffect.h>
#include "Application.h"
#include "LocalVoxelsOverlay.h" #include "LocalVoxelsOverlay.h"
#include "voxels/VoxelSystem.h" #include "voxels/VoxelSystem.h"

View file

@ -8,6 +8,9 @@
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include <GlowEffect.h>
#include "../../Menu.h" #include "../../Menu.h"
#include "ModelOverlay.h" #include "ModelOverlay.h"

View file

@ -12,9 +12,9 @@
#ifndef hifi_ModelOverlay_h #ifndef hifi_ModelOverlay_h
#define hifi_ModelOverlay_h #define hifi_ModelOverlay_h
#include "Base3DOverlay.h" #include <Model.h>
#include "../../renderer/Model.h" #include "Base3DOverlay.h"
class ModelOverlay : public Base3DOverlay { class ModelOverlay : public Base3DOverlay {
Q_OBJECT Q_OBJECT

View file

@ -12,10 +12,11 @@
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include <QGLWidget> #include <QGLWidget>
#include <GlowEffect.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include "Rectangle3DOverlay.h" #include "Rectangle3DOverlay.h"
#include "renderer/GlowEffect.h"
Rectangle3DOverlay::Rectangle3DOverlay() { Rectangle3DOverlay::Rectangle3DOverlay() {
} }

View file

@ -12,11 +12,12 @@
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include <QGLWidget> #include <QGLWidget>
#include <GlowEffect.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include "Sphere3DOverlay.h" #include "Sphere3DOverlay.h"
#include "Application.h" #include "Application.h"
#include "renderer/GlowEffect.h"
Sphere3DOverlay::Sphere3DOverlay() { Sphere3DOverlay::Sphere3DOverlay() {
} }
@ -61,7 +62,6 @@ void Sphere3DOverlay::render(RenderArgs* args) {
glm::vec3 positionToCenter = center - position; glm::vec3 positionToCenter = center - position;
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z); glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
glScalef(dimensions.x, dimensions.y, dimensions.z); glScalef(dimensions.x, dimensions.y, dimensions.z);
//Application::getInstance()->getDeferredLightingEffect()->renderSolidCube(1.0f);
if (_isSolid) { if (_isSolid) {
DependencyManager::get<GeometryCache>()->renderSphere(1.0f, SLICES, SLICES); DependencyManager::get<GeometryCache>()->renderSphere(1.0f, SLICES, SLICES);
} else { } else {

View file

@ -11,6 +11,7 @@
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include <GlowEffect.h>
#include <VoxelConstants.h> #include <VoxelConstants.h>
#include "Application.h" #include "Application.h"
@ -36,7 +37,7 @@ VoxelFade::VoxelFade(FadeDirection direction, float red, float green, float blue
} }
void VoxelFade::render() { void VoxelFade::render() {
Application::getInstance()->getGlowEffect()->begin(); DependencyManager::get<GlowEffect>()->begin();
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glPushMatrix(); glPushMatrix();
@ -52,7 +53,7 @@ void VoxelFade::render() {
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
Application::getInstance()->getGlowEffect()->end(); DependencyManager::get<GlowEffect>()->end();
opacity *= (direction == FADE_OUT) ? FADE_OUT_STEP : FADE_IN_STEP; opacity *= (direction == FADE_OUT) ? FADE_OUT_STEP : FADE_IN_STEP;
} }

View file

@ -14,18 +14,20 @@
#include <iostream> // to load voxels from file #include <iostream> // to load voxels from file
#include <fstream> // to load voxels from file #include <fstream> // to load voxels from file
#include <gpu/GPUConfig.h>
#include <OctalCode.h> #include <OctalCode.h>
#include <PacketHeaders.h> #include <PacketHeaders.h>
#include <PathUtils.h>
#include <PerfStat.h> #include <PerfStat.h>
#include <ProgramObject.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include <NodeList.h> #include <NodeList.h>
#include <glm/gtc/type_ptr.hpp> #include <glm/gtc/type_ptr.hpp>
#include "Application.h" #include "Application.h"
#include "InterfaceConfig.h"
#include "Menu.h" #include "Menu.h"
#include "renderer/ProgramObject.h"
#include "VoxelConstants.h" #include "VoxelConstants.h"
#include "VoxelSystem.h" #include "VoxelSystem.h"
@ -371,9 +373,9 @@ void VoxelSystem::initVoxelMemory() {
// create our simple fragment shader if we're the first system to init // create our simple fragment shader if we're the first system to init
if (!_program.isLinked()) { if (!_program.isLinked()) {
_program.addShaderFromSourceFile(QGLShader::Vertex, _program.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/voxel.vert"); PathUtils::resourcesPath() + "shaders/voxel.vert");
_program.addShaderFromSourceFile(QGLShader::Fragment, _program.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/voxel.frag"); PathUtils::resourcesPath() + "shaders/voxel.frag");
_program.link(); _program.link();
} }
_initialized = true; _initialized = true;
@ -1644,9 +1646,9 @@ unsigned long VoxelSystem::getVoxelMemoryUsageGPU() {
void VoxelSystem::bindPerlinModulateProgram() { void VoxelSystem::bindPerlinModulateProgram() {
if (!_perlinModulateProgram.isLinked()) { if (!_perlinModulateProgram.isLinked()) {
_perlinModulateProgram.addShaderFromSourceFile(QGLShader::Vertex, _perlinModulateProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/perlin_modulate.vert"); PathUtils::resourcesPath() + "shaders/perlin_modulate.vert");
_perlinModulateProgram.addShaderFromSourceFile(QGLShader::Fragment, _perlinModulateProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/perlin_modulate.frag"); PathUtils::resourcesPath() + "shaders/perlin_modulate.frag");
_perlinModulateProgram.link(); _perlinModulateProgram.link();
_perlinModulateProgram.bind(); _perlinModulateProgram.bind();

View file

@ -15,30 +15,31 @@
#include <QScriptEngine> #include <QScriptEngine>
#include <QScriptValue> #include <QScriptValue>
#include <ResourceCache.h> #include <DependencyManager.h>
#include <FBXReader.h> #include <FBXReader.h>
#include <ResourceCache.h>
class Animation; class Animation;
typedef QSharedPointer<Animation> AnimationPointer; typedef QSharedPointer<Animation> AnimationPointer;
/// Scriptable interface for FBX animation loading. /// Scriptable interface for FBX animation loading.
class AnimationCache : public ResourceCache { class AnimationCache : public ResourceCache, public DependencyManager::Dependency {
Q_OBJECT Q_OBJECT
public: public:
AnimationCache(QObject* parent = NULL);
Q_INVOKABLE AnimationPointer getAnimation(const QString& url) { return getAnimation(QUrl(url)); } Q_INVOKABLE AnimationPointer getAnimation(const QString& url) { return getAnimation(QUrl(url)); }
Q_INVOKABLE AnimationPointer getAnimation(const QUrl& url); Q_INVOKABLE AnimationPointer getAnimation(const QUrl& url);
protected: protected:
virtual QSharedPointer<Resource> createResource(const QUrl& url, virtual QSharedPointer<Resource> createResource(const QUrl& url,
const QSharedPointer<Resource>& fallback, bool delayLoad, const void* extra); const QSharedPointer<Resource>& fallback, bool delayLoad, const void* extra);
private:
AnimationCache(QObject* parent = NULL);
virtual ~AnimationCache() { }
friend class DependencyManager;
}; };
Q_DECLARE_METATYPE(AnimationPointer) Q_DECLARE_METATYPE(AnimationPointer)

View file

@ -285,7 +285,6 @@ void ModelEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBit
QMap<QString, AnimationPointer> ModelEntityItem::_loadedAnimations; // TODO: improve cleanup by leveraging the AnimationPointer(s) QMap<QString, AnimationPointer> ModelEntityItem::_loadedAnimations; // TODO: improve cleanup by leveraging the AnimationPointer(s)
AnimationCache ModelEntityItem::_animationCache;
// This class/instance will cleanup the animations once unloaded. // This class/instance will cleanup the animations once unloaded.
class EntityAnimationsBookkeeper { class EntityAnimationsBookkeeper {
@ -309,7 +308,7 @@ Animation* ModelEntityItem::getAnimation(const QString& url) {
// if we don't already have this model then create it and initialize it // if we don't already have this model then create it and initialize it
if (_loadedAnimations.find(url) == _loadedAnimations.end()) { if (_loadedAnimations.find(url) == _loadedAnimations.end()) {
animation = _animationCache.getAnimation(url); animation = DependencyManager::get<AnimationCache>()->getAnimation(url);
_loadedAnimations[url] = animation; _loadedAnimations[url] = animation;
} else { } else {
animation = _loadedAnimations[url]; animation = _loadedAnimations[url];

View file

@ -19,6 +19,7 @@
#include <OpenGL/glext.h> #include <OpenGL/glext.h>
#elif defined(WIN32) #elif defined(WIN32)
#include <windowshacks.h>
#include <GL/glew.h> #include <GL/glew.h>
#include <GL/wglew.h> #include <GL/wglew.h>

View file

@ -0,0 +1,37 @@
set(TARGET_NAME render-utils)
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
setup_hifi_library(Widgets OpenGL Network Script)
include_glm()
link_hifi_libraries(shared gpu)
if (APPLE)
# link in required OS X frameworks and include the right GL headers
find_library(OpenGL OpenGL)
#target_link_libraries(${TARGET_NAME} ${OpenGL})
else (APPLE)
find_package(OpenGL REQUIRED)
if (${OPENGL_INCLUDE_DIR})
include_directories(SYSTEM "${OPENGL_INCLUDE_DIR}")
endif ()
# link target to external libraries
if (WIN32)
find_package(GLEW REQUIRED)
include_directories(${GLEW_INCLUDE_DIRS})
find_package(GLUT REQUIRED)
include_directories(SYSTEM "${GLUT_INCLUDE_DIRS}")
# we're using static GLEW, so define GLEW_STATIC
add_definitions(-DGLEW_STATIC)
target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}")
endif()
endif (APPLE)
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()

View file

@ -10,29 +10,31 @@
// //
// include this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL // include this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL
#include "InterfaceConfig.h" #include <gpu/GPUConfig.h>
#include <QOpenGLFramebufferObject> #include <QOpenGLFramebufferObject>
#include <glm/gtc/random.hpp> #include <glm/gtc/random.hpp>
#include <PathUtils.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include "Application.h" #include "AmbientOcclusionEffect.h"
#include "GlowEffect.h"
#include "ProgramObject.h" #include "ProgramObject.h"
#include "RenderUtil.h" #include "RenderUtil.h"
#include "TextureCache.h"
#include "AmbientOcclusionEffect.h"
const int ROTATION_WIDTH = 4; const int ROTATION_WIDTH = 4;
const int ROTATION_HEIGHT = 4; const int ROTATION_HEIGHT = 4;
void AmbientOcclusionEffect::init() { void AmbientOcclusionEffect::init(ViewStateInterface* viewState) {
_viewState = viewState; // we will use this for view state services
_occlusionProgram = new ProgramObject(); _occlusionProgram = new ProgramObject();
_occlusionProgram->addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() _occlusionProgram->addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath()
+ "shaders/ambient_occlusion.vert"); + "shaders/ambient_occlusion.vert");
_occlusionProgram->addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() _occlusionProgram->addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath()
+ "shaders/ambient_occlusion.frag"); + "shaders/ambient_occlusion.frag");
_occlusionProgram->link(); _occlusionProgram->link();
@ -82,8 +84,8 @@ void AmbientOcclusionEffect::init() {
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
_blurProgram = new ProgramObject(); _blurProgram = new ProgramObject();
_blurProgram->addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + "shaders/ambient_occlusion.vert"); _blurProgram->addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/ambient_occlusion.vert");
_blurProgram->addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/occlusion_blur.frag"); _blurProgram->addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/occlusion_blur.frag");
_blurProgram->link(); _blurProgram->link();
_blurProgram->bind(); _blurProgram->bind();
@ -104,13 +106,12 @@ void AmbientOcclusionEffect::render() {
glBindTexture(GL_TEXTURE_2D, _rotationTextureID); glBindTexture(GL_TEXTURE_2D, _rotationTextureID);
// render with the occlusion shader to the secondary/tertiary buffer // render with the occlusion shader to the secondary/tertiary buffer
QOpenGLFramebufferObject* freeFBO = Application::getInstance()->getGlowEffect()->getFreeFramebufferObject(); QOpenGLFramebufferObject* freeFBO = DependencyManager::get<GlowEffect>()->getFreeFramebufferObject();
freeFBO->bind(); freeFBO->bind();
float left, right, bottom, top, nearVal, farVal; float left, right, bottom, top, nearVal, farVal;
glm::vec4 nearClipPlane, farClipPlane; glm::vec4 nearClipPlane, farClipPlane;
Application::getInstance()->computeOffAxisFrustum( _viewState->computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
int viewport[4]; int viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport); glGetIntegerv(GL_VIEWPORT, viewport);

View file

@ -12,18 +12,24 @@
#ifndef hifi_AmbientOcclusionEffect_h #ifndef hifi_AmbientOcclusionEffect_h
#define hifi_AmbientOcclusionEffect_h #define hifi_AmbientOcclusionEffect_h
#include <DependencyManager.h>
#include "ViewStateInterface.h"
class ProgramObject; class ProgramObject;
/// A screen space ambient occlusion effect. See John Chapman's tutorial at /// A screen space ambient occlusion effect. See John Chapman's tutorial at
/// http://john-chapman-graphics.blogspot.co.uk/2013/01/ssao-tutorial.html for reference. /// http://john-chapman-graphics.blogspot.co.uk/2013/01/ssao-tutorial.html for reference.
class AmbientOcclusionEffect { class AmbientOcclusionEffect: public DependencyManager::Dependency {
public: public:
void init(); void init(ViewStateInterface* viewState);
void render(); void render();
private: private:
AmbientOcclusionEffect() {}
virtual ~AmbientOcclusionEffect() {}
friend class DependencyManager;
ProgramObject* _occlusionProgram; ProgramObject* _occlusionProgram;
int _nearLocation; int _nearLocation;
@ -38,6 +44,7 @@ private:
int _blurScaleLocation; int _blurScaleLocation;
GLuint _rotationTextureID; GLuint _rotationTextureID;
ViewStateInterface* _viewState;
}; };
#endif // hifi_AmbientOcclusionEffect_h #endif // hifi_AmbientOcclusionEffect_h

View file

@ -10,11 +10,11 @@
// //
#include "AnimationHandle.h" #include "AnimationHandle.h"
#include "Application.h" #include "Model.h"
void AnimationHandle::setURL(const QUrl& url) { void AnimationHandle::setURL(const QUrl& url) {
if (_url != url) { if (_url != url) {
_animation = Application::getInstance()->getAnimationCache()->getAnimation(_url = url); _animation = DependencyManager::get<AnimationCache>()->getAnimation(_url = url);
_jointMappings.clear(); _jointMappings.clear();
} }
} }

View file

@ -10,17 +10,35 @@
// //
// include this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL // include this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL
#include "InterfaceConfig.h" #include <gpu/GPUConfig.h>
// TODO: remove these once we migrate away from GLUT calls
#if defined(__APPLE__)
#include <GLUT/glut.h>
#elif defined(WIN32)
#include <GL/glut.h>
#else
#include <GL/glut.h>
#endif
#include <QOpenGLFramebufferObject> #include <QOpenGLFramebufferObject>
#include "Application.h" #include <GLMHelpers.h>
#include "DeferredLightingEffect.h" #include <PathUtils.h>
#include "RenderUtil.h"
void DeferredLightingEffect::init() {
_simpleProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + "shaders/simple.vert"); #include "DeferredLightingEffect.h"
_simpleProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/simple.frag"); #include "GeometryCache.h"
#include "GlowEffect.h"
#include "RenderUtil.h"
#include "TextureCache.h"
void DeferredLightingEffect::init(ViewStateInterface* viewState) {
_viewState = viewState;
_simpleProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/simple.vert");
_simpleProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/simple.frag");
_simpleProgram.link(); _simpleProgram.link();
_simpleProgram.bind(); _simpleProgram.bind();
@ -39,7 +57,7 @@ void DeferredLightingEffect::init() {
void DeferredLightingEffect::bindSimpleProgram() { void DeferredLightingEffect::bindSimpleProgram() {
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, true, true); DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, true, true);
_simpleProgram.bind(); _simpleProgram.bind();
_simpleProgram.setUniformValue(_glowIntensityLocation, Application::getInstance()->getGlowEffect()->getIntensity()); _simpleProgram.setUniformValue(_glowIntensityLocation, DependencyManager::get<GlowEffect>()->getIntensity());
glDisable(GL_BLEND); glDisable(GL_BLEND);
} }
@ -144,7 +162,7 @@ void DeferredLightingEffect::render() {
QOpenGLFramebufferObject* primaryFBO = textureCache->getPrimaryFramebufferObject(); QOpenGLFramebufferObject* primaryFBO = textureCache->getPrimaryFramebufferObject();
primaryFBO->release(); primaryFBO->release();
QOpenGLFramebufferObject* freeFBO = Application::getInstance()->getGlowEffect()->getFreeFramebufferObject(); QOpenGLFramebufferObject* freeFBO = DependencyManager::get<GlowEffect>()->getFreeFramebufferObject();
freeFBO->bind(); freeFBO->bind();
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
@ -173,19 +191,18 @@ void DeferredLightingEffect::render() {
ProgramObject* program = &_directionalLight; ProgramObject* program = &_directionalLight;
const LightLocations* locations = &_directionalLightLocations; const LightLocations* locations = &_directionalLightLocations;
bool shadowsEnabled = Menu::getInstance()->getShadowsEnabled(); bool shadowsEnabled = _viewState->getShadowsEnabled();
if (shadowsEnabled) { if (shadowsEnabled) {
glActiveTexture(GL_TEXTURE4); glActiveTexture(GL_TEXTURE4);
glBindTexture(GL_TEXTURE_2D, textureCache->getShadowDepthTextureID()); glBindTexture(GL_TEXTURE_2D, textureCache->getShadowDepthTextureID());
program = &_directionalLightShadowMap; program = &_directionalLightShadowMap;
locations = &_directionalLightShadowMapLocations; locations = &_directionalLightShadowMapLocations;
if (Menu::getInstance()->isOptionChecked(MenuOption::CascadedShadows)) { if (_viewState->getCascadeShadowsEnabled()) {
program = &_directionalLightCascadedShadowMap; program = &_directionalLightCascadedShadowMap;
locations = &_directionalLightCascadedShadowMapLocations; locations = &_directionalLightCascadedShadowMapLocations;
_directionalLightCascadedShadowMap.bind(); _directionalLightCascadedShadowMap.bind();
_directionalLightCascadedShadowMap.setUniform(locations->shadowDistances, _directionalLightCascadedShadowMap.setUniform(locations->shadowDistances, _viewState->getShadowDistances());
Application::getInstance()->getShadowDistances());
} else { } else {
program->bind(); program->bind();
@ -199,8 +216,7 @@ void DeferredLightingEffect::render() {
float left, right, bottom, top, nearVal, farVal; float left, right, bottom, top, nearVal, farVal;
glm::vec4 nearClipPlane, farClipPlane; glm::vec4 nearClipPlane, farClipPlane;
Application::getInstance()->computeOffAxisFrustum( _viewState->computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
program->setUniformValue(locations->nearLocation, nearVal); program->setUniformValue(locations->nearLocation, nearVal);
float depthScale = (farVal - nearVal) / farVal; float depthScale = (farVal - nearVal) / farVal;
program->setUniformValue(locations->depthScale, depthScale); program->setUniformValue(locations->depthScale, depthScale);
@ -235,8 +251,8 @@ void DeferredLightingEffect::render() {
// enlarge the scales slightly to account for tesselation // enlarge the scales slightly to account for tesselation
const float SCALE_EXPANSION = 0.05f; const float SCALE_EXPANSION = 0.05f;
const glm::vec3& eyePoint = Application::getInstance()->getDisplayViewFrustum()->getPosition(); const glm::vec3& eyePoint = _viewState->getCurrentViewFrustum()->getPosition();
float nearRadius = glm::distance(eyePoint, Application::getInstance()->getDisplayViewFrustum()->getNearTopLeft()); float nearRadius = glm::distance(eyePoint, _viewState->getCurrentViewFrustum()->getNearTopLeft());
GeometryCache* geometryCache = DependencyManager::get<GeometryCache>(); GeometryCache* geometryCache = DependencyManager::get<GeometryCache>();
@ -394,9 +410,9 @@ void DeferredLightingEffect::render() {
} }
void DeferredLightingEffect::loadLightProgram(const char* name, bool limited, ProgramObject& program, LightLocations& locations) { void DeferredLightingEffect::loadLightProgram(const char* name, bool limited, ProgramObject& program, LightLocations& locations) {
program.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + program.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() +
(limited ? "shaders/deferred_light_limited.vert" : "shaders/deferred_light.vert")); (limited ? "shaders/deferred_light_limited.vert" : "shaders/deferred_light.vert"));
program.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + name); program.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + name);
program.link(); program.link();
program.bind(); program.bind();

View file

@ -14,17 +14,19 @@
#include <QVector> #include <QVector>
#include <DependencyManager.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include "ProgramObject.h" #include "ProgramObject.h"
#include "ViewStateInterface.h"
class PostLightingRenderable; class PostLightingRenderable;
/// Handles deferred lighting for the bits that require it (voxels, metavoxels...) /// Handles deferred lighting for the bits that require it (voxels, metavoxels...)
class DeferredLightingEffect { class DeferredLightingEffect: public DependencyManager::Dependency {
public: public:
void init(); void init(ViewStateInterface* viewState);
/// Returns a reference to a simple program suitable for rendering static /// Returns a reference to a simple program suitable for rendering static
/// untextured geometry (such as that generated by glutSolidSphere, etc.) /// untextured geometry (such as that generated by glutSolidSphere, etc.)
@ -69,6 +71,9 @@ public:
void render(); void render();
private: private:
DeferredLightingEffect() { }
virtual ~DeferredLightingEffect() { }
friend class DependencyManager;
class LightLocations { class LightLocations {
public: public:
@ -119,6 +124,8 @@ private:
QVector<PointLight> _pointLights; QVector<PointLight> _pointLights;
QVector<SpotLight> _spotLights; QVector<SpotLight> _spotLights;
QVector<PostLightingRenderable*> _postLightingRenderables; QVector<PostLightingRenderable*> _postLightingRenderables;
ViewStateInterface* _viewState;
}; };
/// Simple interface for objects that require something to be rendered after deferred lighting. /// Simple interface for objects that require something to be rendered after deferred lighting.

View file

@ -20,8 +20,8 @@
#include <SharedUtil.h> #include <SharedUtil.h>
#include "GeometryCache.h"
#include "TextureCache.h" #include "TextureCache.h"
#include "GeometryCache.h"
GeometryCache::GeometryCache() { GeometryCache::GeometryCache() {
} }

View file

@ -13,7 +13,7 @@
#define hifi_GeometryCache_h #define hifi_GeometryCache_h
// include this before QOpenGLBuffer, which includes an earlier version of OpenGL // include this before QOpenGLBuffer, which includes an earlier version of OpenGL
#include "InterfaceConfig.h" #include <gpu/GPUConfig.h>
#include <QMap> #include <QMap>
#include <QOpenGLBuffer> #include <QOpenGLBuffer>

View file

@ -10,22 +10,28 @@
// //
// include this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL // include this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL
#include "InterfaceConfig.h" #include <gpu/GPUConfig.h>
#include <QGLWidget>
#include <QOpenGLFramebufferObject> #include <QOpenGLFramebufferObject>
#include <QWindow>
#include <PathUtils.h>
#include <PerfStat.h> #include <PerfStat.h>
#include "Application.h"
#include "GlowEffect.h" #include "GlowEffect.h"
#include "ProgramObject.h" #include "ProgramObject.h"
#include "RenderUtil.h" #include "RenderUtil.h"
#include "TextureCache.h"
GlowEffect::GlowEffect() GlowEffect::GlowEffect()
: _initialized(false), : _initialized(false),
_isOddFrame(false), _isOddFrame(false),
_isFirstFrame(true), _isFirstFrame(true),
_intensity(0.0f) { _intensity(0.0f),
_widget(NULL),
_enabled(false) {
} }
GlowEffect::~GlowEffect() { GlowEffect::~GlowEffect() {
@ -47,7 +53,7 @@ QOpenGLFramebufferObject* GlowEffect::getFreeFramebufferObject() const {
static ProgramObject* createProgram(const QString& name) { static ProgramObject* createProgram(const QString& name) {
ProgramObject* program = new ProgramObject(); ProgramObject* program = new ProgramObject();
program->addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/" + name + ".frag"); program->addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/" + name + ".frag");
program->link(); program->link();
program->bind(); program->bind();
@ -57,7 +63,7 @@ static ProgramObject* createProgram(const QString& name) {
return program; return program;
} }
void GlowEffect::init() { void GlowEffect::init(QGLWidget* widget, bool enabled) {
if (_initialized) { if (_initialized) {
qDebug("[ERROR] GlowEffeect is already initialized."); qDebug("[ERROR] GlowEffeect is already initialized.");
return; return;
@ -85,8 +91,19 @@ void GlowEffect::init() {
_diffusionScaleLocation = _diffuseProgram->uniformLocation("diffusionScale"); _diffusionScaleLocation = _diffuseProgram->uniformLocation("diffusionScale");
_initialized = true; _initialized = true;
_widget = widget;
_enabled = enabled;
} }
int GlowEffect::getDeviceWidth() const {
return _widget->width() * (_widget->windowHandle() ? _widget->windowHandle()->devicePixelRatio() : 1.0f);
}
int GlowEffect::getDeviceHeight() const {
return _widget->height() * (_widget->windowHandle() ? _widget->windowHandle()->devicePixelRatio() : 1.0f);
}
void GlowEffect::prepare() { void GlowEffect::prepare() {
DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind(); DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@ -140,15 +157,14 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
QOpenGLFramebufferObject* destFBO = toTexture ? QOpenGLFramebufferObject* destFBO = toTexture ?
textureCache->getSecondaryFramebufferObject() : NULL; textureCache->getSecondaryFramebufferObject() : NULL;
if (!Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect) || _isEmpty) { if (!_enabled || _isEmpty) {
// copy the primary to the screen // copy the primary to the screen
if (destFBO && QOpenGLFramebufferObject::hasOpenGLFramebufferBlit()) { if (destFBO && QOpenGLFramebufferObject::hasOpenGLFramebufferBlit()) {
QOpenGLFramebufferObject::blitFramebuffer(destFBO, primaryFBO); QOpenGLFramebufferObject::blitFramebuffer(destFBO, primaryFBO);
} else { } else {
maybeBind(destFBO); maybeBind(destFBO);
if (!destFBO) { if (!destFBO) {
glViewport(0, 0, Application::getInstance()->getGLWidget()->getDeviceWidth(), glViewport(0, 0, getDeviceWidth(), getDeviceHeight());
Application::getInstance()->getGLWidget()->getDeviceHeight());
} }
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
@ -195,9 +211,7 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
} }
maybeBind(destFBO); maybeBind(destFBO);
if (!destFBO) { if (!destFBO) {
glViewport(0, 0, glViewport(0, 0, getDeviceWidth(), getDeviceHeight());
Application::getInstance()->getGLWidget()->getDeviceWidth(),
Application::getInstance()->getGLWidget()->getDeviceHeight());
} }
_addSeparateProgram->bind(); _addSeparateProgram->bind();
renderFullscreenQuad(); renderFullscreenQuad();
@ -224,11 +238,15 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
return destFBO; return destFBO;
} }
void GlowEffect::toggleGlowEffect(bool enabled) {
_enabled = enabled;
}
Glower::Glower(float amount) { Glower::Glower(float amount) {
Application::getInstance()->getGlowEffect()->begin(amount); DependencyManager::get<GlowEffect>()->begin(amount);
} }
Glower::~Glower() { Glower::~Glower() {
Application::getInstance()->getGlowEffect()->end(); DependencyManager::get<GlowEffect>()->end();
} }

View file

@ -12,26 +12,29 @@
#ifndef hifi_GlowEffect_h #ifndef hifi_GlowEffect_h
#define hifi_GlowEffect_h #define hifi_GlowEffect_h
#include <gpu/GPUConfig.h>
#include <QObject> #include <QObject>
#include <QGLWidget>
#include <QStack> #include <QStack>
#include <DependencyManager.h>
class QOpenGLFramebufferObject; class QOpenGLFramebufferObject;
class ProgramObject; class ProgramObject;
/// A generic full screen glow effect. /// A generic full screen glow effect.
class GlowEffect : public QObject { class GlowEffect : public QObject, public DependencyManager::Dependency {
Q_OBJECT Q_OBJECT
public: public:
GlowEffect();
~GlowEffect();
/// Returns a pointer to the framebuffer object that the glow effect is *not* using for persistent state /// Returns a pointer to the framebuffer object that the glow effect is *not* using for persistent state
/// (either the secondary or the tertiary). /// (either the secondary or the tertiary).
QOpenGLFramebufferObject* getFreeFramebufferObject() const; QOpenGLFramebufferObject* getFreeFramebufferObject() const;
void init(); void init(QGLWidget* widget, bool enabled);
/// Prepares the glow effect for rendering the current frame. To be called before rendering the scene. /// Prepares the glow effect for rendering the current frame. To be called before rendering the scene.
void prepare(); void prepare();
@ -51,7 +54,16 @@ public:
/// \return the framebuffer object to which we rendered, or NULL if to the frame buffer /// \return the framebuffer object to which we rendered, or NULL if to the frame buffer
QOpenGLFramebufferObject* render(bool toTexture = false); QOpenGLFramebufferObject* render(bool toTexture = false);
public slots:
void toggleGlowEffect(bool enabled);
private: private:
GlowEffect();
virtual ~GlowEffect();
friend class DependencyManager;
int getDeviceWidth() const;
int getDeviceHeight() const;
bool _initialized; bool _initialized;
@ -69,6 +81,8 @@ private:
float _intensity; float _intensity;
QStack<float> _intensityStack; QStack<float> _intensityStack;
QGLWidget* _widget;
bool _enabled;
}; };
/// RAII-style glow handler. Applies glow when in scope. /// RAII-style glow handler. Applies glow when in scope.

View file

@ -9,6 +9,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include <gpu/GPUConfig.h>
#include <QMetaType> #include <QMetaType>
#include <QRunnable> #include <QRunnable>
#include <QThreadPool> #include <QThreadPool>
@ -18,17 +20,20 @@
#include <CapsuleShape.h> #include <CapsuleShape.h>
#include <GeometryUtil.h> #include <GeometryUtil.h>
#include <gpu/Batch.h>
#include <gpu/GLBackend.h>
#include <PathUtils.h>
#include <PerfStat.h> #include <PerfStat.h>
#include <PhysicsEntity.h> #include <PhysicsEntity.h>
#include <ShapeCollider.h> #include <ShapeCollider.h>
#include <SphereShape.h> #include <SphereShape.h>
#include "AnimationHandle.h" #include "AnimationHandle.h"
#include "Application.h" #include "DeferredLightingEffect.h"
#include "GlowEffect.h"
#include "Model.h" #include "Model.h"
#include "gpu/Batch.h"
#include "gpu/GLBackend.h"
#define GLBATCH( call ) batch._##call #define GLBATCH( call ) batch._##call
//#define GLBATCH( call ) call //#define GLBATCH( call ) call
@ -58,7 +63,9 @@ Model::Model(QObject* parent) :
_meshGroupsKnown(false) { _meshGroupsKnown(false) {
// we may have been created in the network thread, but we live in the main thread // we may have been created in the network thread, but we live in the main thread
moveToThread(Application::getInstance()->thread()); if (_viewState) {
moveToThread(_viewState->getMainThread());
}
} }
Model::~Model() { Model::~Model() {
@ -104,6 +111,8 @@ Model::SkinLocations Model::_skinNormalSpecularMapLocations;
Model::SkinLocations Model::_skinShadowLocations; Model::SkinLocations Model::_skinShadowLocations;
Model::SkinLocations Model::_skinTranslucentLocations; Model::SkinLocations Model::_skinTranslucentLocations;
ViewStateInterface* Model::_viewState = NULL;
void Model::setScale(const glm::vec3& scale) { void Model::setScale(const glm::vec3& scale) {
setScaleInternal(scale); setScaleInternal(scale);
// if anyone sets scale manually, then we are no longer scaled to fit // if anyone sets scale manually, then we are no longer scaled to fit
@ -222,109 +231,109 @@ void Model::initJointTransforms() {
void Model::init() { void Model::init() {
if (!_program.isLinked()) { if (!_program.isLinked()) {
_program.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + "shaders/model.vert"); _program.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/model.vert");
_program.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/model.frag"); _program.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/model.frag");
initProgram(_program, _locations); initProgram(_program, _locations);
_normalMapProgram.addShaderFromSourceFile(QGLShader::Vertex, _normalMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/model_normal_map.vert"); PathUtils::resourcesPath() + "shaders/model_normal_map.vert");
_normalMapProgram.addShaderFromSourceFile(QGLShader::Fragment, _normalMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_normal_map.frag"); PathUtils::resourcesPath() + "shaders/model_normal_map.frag");
initProgram(_normalMapProgram, _normalMapLocations); initProgram(_normalMapProgram, _normalMapLocations);
_specularMapProgram.addShaderFromSourceFile(QGLShader::Vertex, _specularMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/model.vert"); PathUtils::resourcesPath() + "shaders/model.vert");
_specularMapProgram.addShaderFromSourceFile(QGLShader::Fragment, _specularMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_specular_map.frag"); PathUtils::resourcesPath() + "shaders/model_specular_map.frag");
initProgram(_specularMapProgram, _specularMapLocations); initProgram(_specularMapProgram, _specularMapLocations);
_normalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex, _normalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/model_normal_map.vert"); PathUtils::resourcesPath() + "shaders/model_normal_map.vert");
_normalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment, _normalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_normal_specular_map.frag"); PathUtils::resourcesPath() + "shaders/model_normal_specular_map.frag");
initProgram(_normalSpecularMapProgram, _normalSpecularMapLocations); initProgram(_normalSpecularMapProgram, _normalSpecularMapLocations);
_translucentProgram.addShaderFromSourceFile(QGLShader::Vertex, _translucentProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/model.vert"); PathUtils::resourcesPath() + "shaders/model.vert");
_translucentProgram.addShaderFromSourceFile(QGLShader::Fragment, _translucentProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_translucent.frag"); PathUtils::resourcesPath() + "shaders/model_translucent.frag");
initProgram(_translucentProgram, _translucentLocations); initProgram(_translucentProgram, _translucentLocations);
// Lightmap // Lightmap
_lightmapProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + "shaders/model_lightmap.vert"); _lightmapProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/model_lightmap.vert");
_lightmapProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/model_lightmap.frag"); _lightmapProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/model_lightmap.frag");
initProgram(_lightmapProgram, _lightmapLocations); initProgram(_lightmapProgram, _lightmapLocations);
_lightmapNormalMapProgram.addShaderFromSourceFile(QGLShader::Vertex, _lightmapNormalMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/model_lightmap_normal_map.vert"); PathUtils::resourcesPath() + "shaders/model_lightmap_normal_map.vert");
_lightmapNormalMapProgram.addShaderFromSourceFile(QGLShader::Fragment, _lightmapNormalMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_lightmap_normal_map.frag"); PathUtils::resourcesPath() + "shaders/model_lightmap_normal_map.frag");
initProgram(_lightmapNormalMapProgram, _lightmapNormalMapLocations); initProgram(_lightmapNormalMapProgram, _lightmapNormalMapLocations);
_lightmapSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex, _lightmapSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/model_lightmap.vert"); PathUtils::resourcesPath() + "shaders/model_lightmap.vert");
_lightmapSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment, _lightmapSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_lightmap_specular_map.frag"); PathUtils::resourcesPath() + "shaders/model_lightmap_specular_map.frag");
initProgram(_lightmapSpecularMapProgram, _lightmapSpecularMapLocations); initProgram(_lightmapSpecularMapProgram, _lightmapSpecularMapLocations);
_lightmapNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex, _lightmapNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/model_lightmap_normal_map.vert"); PathUtils::resourcesPath() + "shaders/model_lightmap_normal_map.vert");
_lightmapNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment, _lightmapNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_lightmap_normal_specular_map.frag"); PathUtils::resourcesPath() + "shaders/model_lightmap_normal_specular_map.frag");
initProgram(_lightmapNormalSpecularMapProgram, _lightmapNormalSpecularMapLocations); initProgram(_lightmapNormalSpecularMapProgram, _lightmapNormalSpecularMapLocations);
// end lightmap // end lightmap
_shadowProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + "shaders/model_shadow.vert"); _shadowProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/model_shadow.vert");
_shadowProgram.addShaderFromSourceFile(QGLShader::Fragment, _shadowProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_shadow.frag"); PathUtils::resourcesPath() + "shaders/model_shadow.frag");
_skinProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + "shaders/skin_model.vert"); _skinProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/skin_model.vert");
_skinProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/model.frag"); _skinProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/model.frag");
initSkinProgram(_skinProgram, _skinLocations); initSkinProgram(_skinProgram, _skinLocations);
_skinNormalMapProgram.addShaderFromSourceFile(QGLShader::Vertex, _skinNormalMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/skin_model_normal_map.vert"); PathUtils::resourcesPath() + "shaders/skin_model_normal_map.vert");
_skinNormalMapProgram.addShaderFromSourceFile(QGLShader::Fragment, _skinNormalMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_normal_map.frag"); PathUtils::resourcesPath() + "shaders/model_normal_map.frag");
initSkinProgram(_skinNormalMapProgram, _skinNormalMapLocations); initSkinProgram(_skinNormalMapProgram, _skinNormalMapLocations);
_skinSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex, _skinSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/skin_model.vert"); PathUtils::resourcesPath() + "shaders/skin_model.vert");
_skinSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment, _skinSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_specular_map.frag"); PathUtils::resourcesPath() + "shaders/model_specular_map.frag");
initSkinProgram(_skinSpecularMapProgram, _skinSpecularMapLocations); initSkinProgram(_skinSpecularMapProgram, _skinSpecularMapLocations);
_skinNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex, _skinNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/skin_model_normal_map.vert"); PathUtils::resourcesPath() + "shaders/skin_model_normal_map.vert");
_skinNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment, _skinNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_normal_specular_map.frag"); PathUtils::resourcesPath() + "shaders/model_normal_specular_map.frag");
initSkinProgram(_skinNormalSpecularMapProgram, _skinNormalSpecularMapLocations); initSkinProgram(_skinNormalSpecularMapProgram, _skinNormalSpecularMapLocations);
_skinShadowProgram.addShaderFromSourceFile(QGLShader::Vertex, _skinShadowProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/skin_model_shadow.vert"); PathUtils::resourcesPath() + "shaders/skin_model_shadow.vert");
_skinShadowProgram.addShaderFromSourceFile(QGLShader::Fragment, _skinShadowProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_shadow.frag"); PathUtils::resourcesPath() + "shaders/model_shadow.frag");
initSkinProgram(_skinShadowProgram, _skinShadowLocations); initSkinProgram(_skinShadowProgram, _skinShadowLocations);
_skinTranslucentProgram.addShaderFromSourceFile(QGLShader::Vertex, _skinTranslucentProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/skin_model.vert"); PathUtils::resourcesPath() + "shaders/skin_model.vert");
_skinTranslucentProgram.addShaderFromSourceFile(QGLShader::Fragment, _skinTranslucentProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_translucent.frag"); PathUtils::resourcesPath() + "shaders/model_translucent.frag");
initSkinProgram(_skinTranslucentProgram, _skinTranslucentLocations); initSkinProgram(_skinTranslucentProgram, _skinTranslucentLocations);
} }
@ -491,7 +500,7 @@ bool Model::renderTriangleProxies() {
glPushMatrix(); glPushMatrix();
glTranslatef(center.x, center.y, center.z); glTranslatef(center.x, center.y, center.z);
glScalef(dimensions.x, dimensions.y, dimensions.z); glScalef(dimensions.x, dimensions.y, dimensions.z);
Application::getInstance()->getDeferredLightingEffect()->renderWireCube(1.0f); DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f);
glPopMatrix(); glPopMatrix();
} }
@ -712,6 +721,9 @@ bool Model::render(float alpha, RenderMode mode, RenderArgs* args) {
bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) { bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) {
PROFILE_RANGE(__FUNCTION__); PROFILE_RANGE(__FUNCTION__);
if (!_viewState) {
return false;
}
// Let's introduce a gpu::Batch to capture all the calls to the graphics api // Let's introduce a gpu::Batch to capture all the calls to the graphics api
_renderBatch.clear(); _renderBatch.clear();
@ -722,7 +734,7 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) {
if (_transforms.empty()) { if (_transforms.empty()) {
_transforms.push_back(Transform()); _transforms.push_back(Transform());
} }
_transforms[0] = Application::getInstance()->getViewTransform(); _transforms[0] = _viewState->getViewTransform();
// apply entity translation offset to the viewTransform in one go (it's a preTranslate because viewTransform goes from world to eye space) // apply entity translation offset to the viewTransform in one go (it's a preTranslate because viewTransform goes from world to eye space)
_transforms[0].preTranslate(-_translation); _transforms[0].preTranslate(-_translation);
@ -865,7 +877,7 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) {
} }
// restore all the default material settings // restore all the default material settings
Application::getInstance()->setupWorldLight(); _viewState->setupWorldLight();
if (args) { if (args) {
args->_translucentMeshPartsRendered = translucentMeshPartsRendered; args->_translucentMeshPartsRendered = translucentMeshPartsRendered;
@ -1665,7 +1677,7 @@ void Model::setupBatchTransform(gpu::Batch& batch) {
if (_transforms.empty()) { if (_transforms.empty()) {
_transforms.push_back(Transform()); _transforms.push_back(Transform());
} }
_transforms[0] = Application::getInstance()->getViewTransform(); _transforms[0] = _viewState->getViewTransform();
_transforms[0].preTranslate(-_translation); _transforms[0].preTranslate(-_translation);
batch.setViewTransform(_transforms[0]); batch.setViewTransform(_transforms[0]);
} }
@ -1825,7 +1837,7 @@ void Model::endScene(RenderMode mode, RenderArgs* args) {
} }
// restore all the default material settings // restore all the default material settings
Application::getInstance()->setupWorldLight(); _viewState->setupWorldLight();
} }
@ -2321,11 +2333,9 @@ int Model::renderMeshes(gpu::Batch& batch, RenderMode mode, bool translucent, fl
int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMode mode, bool translucent, float alphaThreshold, RenderArgs* args, int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMode mode, bool translucent, float alphaThreshold, RenderArgs* args,
Locations* locations, SkinLocations* skinLocations) { Locations* locations, SkinLocations* skinLocations) {
PROFILE_RANGE(__FUNCTION__); PROFILE_RANGE(__FUNCTION__);
bool dontCullOutOfViewMeshParts = Menu::getInstance()->isOptionChecked(MenuOption::DontCullOutOfViewMeshParts);
bool cullTooSmallMeshParts = !Menu::getInstance()->isOptionChecked(MenuOption::DontCullTooSmallMeshParts);
bool dontReduceMaterialSwitches = Menu::getInstance()->isOptionChecked(MenuOption::DontReduceMaterialSwitches);
TextureCache* textureCache = DependencyManager::get<TextureCache>(); TextureCache* textureCache = DependencyManager::get<TextureCache>();
GlowEffect* glowEffect = DependencyManager::get<GlowEffect>();
QString lastMaterialID; QString lastMaterialID;
int meshPartsRendered = 0; int meshPartsRendered = 0;
updateVisibleJointStates(); updateVisibleJointStates();
@ -2360,11 +2370,10 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
args->_meshesConsidered++; args->_meshesConsidered++;
if (args->_viewFrustum) { if (args->_viewFrustum) {
shouldRender = dontCullOutOfViewMeshParts || shouldRender = args->_viewFrustum->boxInFrustum(_calculatedMeshBoxes.at(i)) != ViewFrustum::OUTSIDE;
args->_viewFrustum->boxInFrustum(_calculatedMeshBoxes.at(i)) != ViewFrustum::OUTSIDE; if (shouldRender) {
if (shouldRender && cullTooSmallMeshParts) {
float distance = args->_viewFrustum->distanceToCamera(_calculatedMeshBoxes.at(i).calcCenter()); float distance = args->_viewFrustum->distanceToCamera(_calculatedMeshBoxes.at(i).calcCenter());
shouldRender = Menu::getInstance()->shouldRenderMesh(_calculatedMeshBoxes.at(i).getLargestDimension(), shouldRender = !_viewState ? false : _viewState->shouldRenderMesh(_calculatedMeshBoxes.at(i).getLargestDimension(),
distance); distance);
if (!shouldRender) { if (!shouldRender) {
args->_meshesTooSmall++; args->_meshesTooSmall++;
@ -2420,7 +2429,7 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
GLBATCH(glBindTexture)(GL_TEXTURE_2D, 0); GLBATCH(glBindTexture)(GL_TEXTURE_2D, 0);
} else { } else {
if (dontReduceMaterialSwitches || lastMaterialID != part.materialID) { if (lastMaterialID != part.materialID) {
const bool wantDebug = false; const bool wantDebug = false;
if (wantDebug) { if (wantDebug) {
qDebug() << "Material Changed ---------------------------------------------"; qDebug() << "Material Changed ---------------------------------------------";
@ -2430,7 +2439,7 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
glm::vec4 diffuse = glm::vec4(part.diffuseColor, part.opacity); glm::vec4 diffuse = glm::vec4(part.diffuseColor, part.opacity);
if (!(translucent && alphaThreshold == 0.0f)) { if (!(translucent && alphaThreshold == 0.0f)) {
GLBATCH(glAlphaFunc)(GL_EQUAL, diffuse.a = Application::getInstance()->getGlowEffect()->getIntensity()); GLBATCH(glAlphaFunc)(GL_EQUAL, diffuse.a = glowEffect->getIntensity());
} }
glm::vec4 specular = glm::vec4(part.specularColor, 1.0f); glm::vec4 specular = glm::vec4(part.specularColor, 1.0f);
GLBATCH(glMaterialfv)(GL_FRONT, GL_AMBIENT, (const float*)&diffuse); GLBATCH(glMaterialfv)(GL_FRONT, GL_AMBIENT, (const float*)&diffuse);

View file

@ -12,23 +12,27 @@
#ifndef hifi_Model_h #ifndef hifi_Model_h
#define hifi_Model_h #define hifi_Model_h
#include <gpu/GPUConfig.h>
#include <QBitArray> #include <QBitArray>
#include <QObject> #include <QObject>
#include <QUrl> #include <QUrl>
#include "Transform.h"
#include <AABox.h> #include <AABox.h>
#include <AnimationCache.h> #include <AnimationCache.h>
#include <DependencyManager.h> #include <DependencyManager.h>
#include <GeometryUtil.h> #include <GeometryUtil.h>
#include <gpu/Stream.h>
#include <gpu/Batch.h>
#include <PhysicsEntity.h> #include <PhysicsEntity.h>
#include <Transform.h>
#include "AnimationHandle.h" #include "AnimationHandle.h"
#include "GeometryCache.h" #include "GeometryCache.h"
#include "InterfaceConfig.h"
#include "JointState.h" #include "JointState.h"
#include "ProgramObject.h" #include "ProgramObject.h"
#include "TextureCache.h" #include "TextureCache.h"
#include "ViewStateInterface.h"
class QScriptEngine; class QScriptEngine;
@ -36,8 +40,6 @@ class Shape;
#include "RenderArgs.h" #include "RenderArgs.h"
class ViewFrustum; class ViewFrustum;
#include "gpu/Stream.h"
#include "gpu/Batch.h"
/// A generic 3D model displaying geometry loaded from a URL. /// A generic 3D model displaying geometry loaded from a URL.
class Model : public QObject, public PhysicsEntity { class Model : public QObject, public PhysicsEntity {
@ -45,6 +47,8 @@ class Model : public QObject, public PhysicsEntity {
public: public:
static void setViewStateInterface(ViewStateInterface* viewState) { _viewState = viewState; }
Model(QObject* parent = NULL); Model(QObject* parent = NULL);
virtual ~Model(); virtual ~Model();
@ -454,6 +458,9 @@ private:
static int renderMeshesForModelsInScene(gpu::Batch& batch, RenderMode mode, bool translucent, float alphaThreshold, static int renderMeshesForModelsInScene(gpu::Batch& batch, RenderMode mode, bool translucent, float alphaThreshold,
bool hasLightmap, bool hasTangents, bool hasSpecular, bool isSkinned, RenderArgs* args); bool hasLightmap, bool hasTangents, bool hasSpecular, bool isSkinned, RenderArgs* args);
static ViewStateInterface* _viewState;
}; };
Q_DECLARE_METATYPE(QPointer<Model>) Q_DECLARE_METATYPE(QPointer<Model>)

View file

@ -9,9 +9,10 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include "ProgramObject.h"
#include <glm/gtc/type_ptr.hpp> #include <glm/gtc/type_ptr.hpp>
#include "ProgramObject.h"
ProgramObject::ProgramObject(QObject* parent) : QGLShaderProgram(parent) { ProgramObject::ProgramObject(QObject* parent) : QGLShaderProgram(parent) {
} }

View file

@ -9,7 +9,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include "InterfaceConfig.h" #include <gpu/GPUConfig.h>
#include "RenderUtil.h" #include "RenderUtil.h"
void renderFullscreenQuad(float sMin, float sMax, float tMin, float tMax) { void renderFullscreenQuad(float sMin, float sMax, float tMin, float tMax) {

View file

@ -10,7 +10,7 @@
// //
// include this before QGLWidget, which includes an earlier version of OpenGL // include this before QGLWidget, which includes an earlier version of OpenGL
#include "InterfaceConfig.h" #include <gpu/GPUConfig.h>
#include <QEvent> #include <QEvent>
#include <QGLWidget> #include <QGLWidget>

View file

@ -12,6 +12,8 @@
#ifndef hifi_TextureCache_h #ifndef hifi_TextureCache_h
#define hifi_TextureCache_h #define hifi_TextureCache_h
#include <gpu/GPUConfig.h>
#include <QImage> #include <QImage>
#include <QMap> #include <QMap>
#include <QGLWidget> #include <QGLWidget>
@ -19,8 +21,6 @@
#include <DependencyManager.h> #include <DependencyManager.h>
#include <ResourceCache.h> #include <ResourceCache.h>
#include "InterfaceConfig.h"
class QOpenGLFramebufferObject; class QOpenGLFramebufferObject;
class NetworkTexture; class NetworkTexture;

View file

@ -0,0 +1,44 @@
//
// ViewStateInterface.h
// interface/src/renderer
//
// Created by Brad Hefta-Gaub on 12/16/14.
// Copyright 2014 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_ViewStateInterface_h
#define hifi_ViewStateInterface_h
#include <ViewFrustum.h>
class Transform;
class QThread;
/// Interface provided by Application to other objects that need access to the current view state details
class ViewStateInterface {
public:
/// Returns the shadow distances for the current view state
virtual const glm::vec3& getShadowDistances() const = 0;
/// Computes the off-axis frustum parameters for the view frustum, taking mirroring into account.
virtual void computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal,
float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const = 0;
/// gets the current view frustum for rendering the view state
virtual ViewFrustum* getCurrentViewFrustum() = 0;
virtual bool getShadowsEnabled() = 0;
virtual bool getCascadeShadowsEnabled() = 0;
virtual QThread* getMainThread() = 0;
virtual const Transform& getViewTransform() const = 0;
virtual void setupWorldLight() = 0;
virtual bool shouldRenderMesh(float largestDimension, float distanceToCamera) = 0;
};
#endif // hifi_ViewStateInterface_h

View file

@ -94,7 +94,6 @@ ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNam
_quatLibrary(), _quatLibrary(),
_vec3Library(), _vec3Library(),
_uuidLibrary(), _uuidLibrary(),
_animationCache(this),
_isUserLoaded(false), _isUserLoaded(false),
_arrayBufferClass(new ArrayBufferClass(this)) _arrayBufferClass(new ArrayBufferClass(this))
{ {
@ -256,7 +255,7 @@ void ScriptEngine::init() {
registerGlobalObject("Quat", &_quatLibrary); registerGlobalObject("Quat", &_quatLibrary);
registerGlobalObject("Vec3", &_vec3Library); registerGlobalObject("Vec3", &_vec3Library);
registerGlobalObject("Uuid", &_uuidLibrary); registerGlobalObject("Uuid", &_uuidLibrary);
registerGlobalObject("AnimationCache", &_animationCache); registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>());
registerGlobalObject("Voxels", &_voxelsScriptingInterface); registerGlobalObject("Voxels", &_voxelsScriptingInterface);

View file

@ -51,7 +51,6 @@ public:
static EntityScriptingInterface* getEntityScriptingInterface() { return &_entityScriptingInterface; } static EntityScriptingInterface* getEntityScriptingInterface() { return &_entityScriptingInterface; }
ArrayBufferClass* getArrayBufferClass() { return _arrayBufferClass; } ArrayBufferClass* getArrayBufferClass() { return _arrayBufferClass; }
AnimationCache* getAnimationCache() { return &_animationCache; }
/// sets the script contents, will return false if failed, will fail if script is already running /// sets the script contents, will return false if failed, will fail if script is already running
bool setScriptContents(const QString& scriptContents, const QString& fileNameString = QString("")); bool setScriptContents(const QString& scriptContents, const QString& fileNameString = QString(""));
@ -149,7 +148,6 @@ private:
Quat _quatLibrary; Quat _quatLibrary;
Vec3 _vec3Library; Vec3 _vec3Library;
ScriptUUID _uuidLibrary; ScriptUUID _uuidLibrary;
AnimationCache _animationCache;
bool _isUserLoaded; bool _isUserLoaded;
ArrayBufferClass* _arrayBufferClass; ArrayBufferClass* _arrayBufferClass;

View file

@ -0,0 +1,25 @@
//
// PathUtils.cpp
// libraries/shared/src
//
// Created by Brad Hefta-Gaub on 12/15/14.
// Copyright 2014 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include <QCoreApplication>
#include <QString>
#include "PathUtils.h"
QString& PathUtils::resourcesPath() {
#ifdef Q_OS_MAC
static QString staticResourcePath = QCoreApplication::applicationDirPath() + "/../Resources/";
#else
static QString staticResourcePath = QCoreApplication::applicationDirPath() + "/resources/";
#endif
return staticResourcePath;
}

View file

@ -0,0 +1,22 @@
//
// PathUtils.h
// libraries/shared/src
//
// Created by Brad Hefta-Gaub on 12/15/14.
// Copyright 2014 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_PathUtils_h
#define hifi_PathUtils_h
#include <QString>
namespace PathUtils {
QString& resourcesPath();
}
#endif // hifi_PathUtils_h

View file

@ -15,7 +15,6 @@
#define hifi_windowshacks_h #define hifi_windowshacks_h
#ifdef WIN32 #ifdef WIN32
#undef NOMINMAX
#include <cmath> #include <cmath>
inline double roundf(double value) { inline double roundf(double value) {