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

This commit is contained in:
Stephen Birarda 2014-12-17 09:23:42 -08:00
commit 737741c13b
103 changed files with 896 additions and 545 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));
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);
_maskedJoints = maskedJoints;
}

View file

@ -76,6 +76,33 @@
}
]
},
{
"name": "scripts",
"label": "Scripts",
"settings": [
{
"name": "persistent_scripts",
"type": "table",
"label": "Persistent Scripts",
"help": "Add the URLs for scripts that you would like to ensure are always running in your domain.",
"columns": [
{
"name": "url",
"label": "Script URL"
},
{
"name": "num_instances",
"label": "# instances",
"default": 1
},
{
"name": "pool",
"label": "Pool"
}
]
}
]
},
{
"name": "audio_env",
"label": "Audio Environment",

View file

@ -363,7 +363,8 @@ function makeTableInputs(setting) {
_.each(setting.columns, function(col) {
html += "<td class='" + Settings.DATA_COL_CLASS + "'name='" + col.name + "'>\
<input type='text' class='form-control' placeholder='" + (col.placeholder ? col.placeholder : "") + "' value=''>\
<input type='text' class='form-control' placeholder='" + (col.placeholder ? col.placeholder : "") + "'\
value='" + (col.default ? col.default : "") + "'>\
</td>"
})
@ -389,8 +390,9 @@ function badgeSidebarForDifferences(changedElement) {
// badge for any settings we have that are not the same or are not present in initialValues
for (var setting in panelJSON) {
if (!_.isEqual(panelJSON[setting], initialPanelJSON[setting])
&& (panelJSON[setting] !== "" || _.has(initialPanelJSON, setting))) {
if ((!_.has(initialPanelJSON, setting) && panelJSON[setting] !== "") ||
(!_.isEqual(panelJSON[setting], initialPanelJSON[setting])
&& (panelJSON[setting] !== "" || _.has(initialPanelJSON, setting)))) {
badgeValue += 1
}
}

View file

@ -233,6 +233,9 @@ void DomainServer::setupNodeListAndAssignments(const QUuid& sessionUUID) {
parseAssignmentConfigs(parsedTypes);
populateDefaultStaticAssignmentsExcludingTypes(parsedTypes);
// check for scripts the user wants to persist from their domain-server config
populateStaticScriptedAssignmentsFromSettings();
LimitedNodeList* nodeList = LimitedNodeList::createInstance(domainServerPort, domainServerDTLSPort);
@ -451,8 +454,6 @@ void DomainServer::parseAssignmentConfigs(QSet<Assignment::Type>& excludedTypes)
if (assignmentType != Assignment::AgentType) {
createStaticAssignmentsForType(assignmentType, assignmentList);
} else {
createScriptedAssignmentsFromList(assignmentList);
}
excludedTypes.insert(assignmentType);
@ -468,35 +469,37 @@ void DomainServer::addStaticAssignmentToAssignmentHash(Assignment* newAssignment
_allAssignments.insert(newAssignment->getUUID(), SharedAssignmentPointer(newAssignment));
}
void DomainServer::createScriptedAssignmentsFromList(const QVariantList &configList) {
foreach(const QVariant& configVariant, configList) {
if (configVariant.canConvert(QMetaType::QVariantMap)) {
QVariantMap configMap = configVariant.toMap();
// make sure we were passed a URL, otherwise this is an invalid scripted assignment
const QString ASSIGNMENT_URL_KEY = "url";
QString assignmentURL = configMap[ASSIGNMENT_URL_KEY].toString();
if (!assignmentURL.isEmpty()) {
// check the json for a pool
const QString ASSIGNMENT_POOL_KEY = "pool";
QString assignmentPool = configMap[ASSIGNMENT_POOL_KEY].toString();
// check for a number of instances, if not passed then default is 1
const QString ASSIGNMENT_INSTANCES_KEY = "instances";
int numInstances = configMap[ASSIGNMENT_INSTANCES_KEY].toInt();
numInstances = (numInstances == 0 ? 1 : numInstances);
qDebug() << "Adding a static scripted assignment from" << assignmentURL;
for (int i = 0; i < numInstances; i++) {
void DomainServer::populateStaticScriptedAssignmentsFromSettings() {
const QString PERSISTENT_SCRIPTS_KEY_PATH = "scripts.persistent_scripts";
const QVariant* persistentScriptsVariant = valueForKeyPath(_settingsManager.getSettingsMap(), PERSISTENT_SCRIPTS_KEY_PATH);
if (persistentScriptsVariant) {
QVariantList persistentScriptsList = persistentScriptsVariant->toList();
foreach(const QVariant& persistentScriptVariant, persistentScriptsList) {
QVariantMap persistentScript = persistentScriptVariant.toMap();
const QString PERSISTENT_SCRIPT_URL_KEY = "url";
const QString PERSISTENT_SCRIPT_NUM_INSTANCES_KEY = "num_instances";
const QString PERSISTENT_SCRIPT_POOL_KEY = "pool";
if (persistentScript.contains(PERSISTENT_SCRIPT_URL_KEY)) {
// check how many instances of this script to add
int numInstances = persistentScript[PERSISTENT_SCRIPT_NUM_INSTANCES_KEY].toInt();
QString scriptURL = persistentScript[PERSISTENT_SCRIPT_URL_KEY].toString();
QString scriptPool = persistentScript.value(PERSISTENT_SCRIPT_POOL_KEY).toString();
qDebug() << "Adding" << numInstances << "of persistent script at URL" << scriptURL << "- pool" << scriptPool;
for (int i = 0; i < numInstances; ++i) {
// add a scripted assignment to the queue for this instance
Assignment* scriptAssignment = new Assignment(Assignment::CreateCommand,
Assignment::AgentType,
assignmentPool);
scriptAssignment->setPayload(assignmentURL.toUtf8());
// scripts passed on CL or via JSON are static - so they are added back to the queue if the node dies
scriptPool);
scriptAssignment->setPayload(scriptURL.toUtf8());
// add it to static hash so we know we have to keep giving it back out
addStaticAssignmentToAssignmentHash(scriptAssignment);
}
}

View file

@ -100,9 +100,9 @@ private:
void parseAssignmentConfigs(QSet<Assignment::Type>& excludedTypes);
void addStaticAssignmentToAssignmentHash(Assignment* newAssignment);
void createScriptedAssignmentsFromList(const QVariantList& configList);
void createStaticAssignmentsForType(Assignment::Type type, const QVariantList& configList);
void populateDefaultStaticAssignmentsExcludingTypes(const QSet<Assignment::Type>& excludedTypes);
void populateStaticScriptedAssignmentsFromSettings();
SharedAssignmentPointer matchingQueuedAssignmentForCheckIn(const QUuid& checkInUUID, NodeType_t nodeType);
SharedAssignmentPointer deployableAssignmentForRequest(const Assignment& requestAssignment);

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 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 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 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 });
}
}

View file

@ -195,7 +195,7 @@ Grid = function(opts) {
Overlays.editOverlay(gridOverlay, {
position: { x: origin.y, y: origin.y, z: -origin.y },
visible: that.visible && that.enabled,
minorGridSpacing: minorGridSpacing,
minorGridWidth: minorGridSpacing,
majorGridEvery: majorGridEvery,
color: gridColor,
alpha: gridAlpha,

View file

@ -107,7 +107,7 @@ endif()
add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS} ${QM})
# 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_package(ZLIB REQUIRED)

View file

@ -54,9 +54,12 @@
#include <AddressManager.h>
#include <AccountManager.h>
#include <AmbientOcclusionEffect.h>
#include <AudioInjector.h>
#include <DeferredLightingEffect.h>
#include <DependencyManager.h>
#include <EntityScriptingInterface.h>
#include <GlowEffect.h>
#include <HFActionEvent.h>
#include <HFBackEvent.h>
#include <LocalVoxelsList.h>
@ -65,7 +68,9 @@
#include <OctalCode.h>
#include <OctreeSceneStats.h>
#include <PacketHeaders.h>
#include <PathUtils.h>
#include <PerfStat.h>
#include <ProgramObject.h>
#include <ResourceCache.h>
#include <SoundCache.h>
#include <UserActivityLogger.h>
@ -85,10 +90,10 @@
#include "devices/TV3DManager.h"
#include "devices/Visage.h"
#include "renderer/ProgramObject.h"
#include "gpu/Batch.h"
#include "gpu/GLBackend.h"
#include "scripting/AccountScriptingInterface.h"
#include "scripting/AudioDeviceScriptingInterface.h"
#include "scripting/ClipboardScriptingInterface.h"
@ -107,6 +112,7 @@
#include "ui/TextRenderer.h"
using namespace std;
// 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) :
QApplication(argc, argv),
_window(new MainWindow(desktop())),
@ -194,9 +191,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
_isVSyncOn(true),
_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
QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
// set the associated application properties
applicationInfo.beginGroup("INFO");
@ -214,7 +212,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
_applicationStartupTime = startup_time;
QFontDatabase::addApplicationFont(Application::resourcesPath() + "styles/Inconsolata.otf");
QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf");
_window->setWindowTitle("Interface");
qInstallMessageHandler(messageHandler);
@ -621,10 +619,10 @@ void Application::paintGL() {
// Set the desired FBO texture size. If it hasn't changed, this does nothing.
// Otherwise, it must rebuild the FBOs
if (OculusManager::isConnected()) {
_textureCache.setFrameBufferSize(OculusManager::getRenderTargetSize());
DependencyManager::get<TextureCache>()->setFrameBufferSize(OculusManager::getRenderTargetSize());
} else {
QSize fbSize = _glWidget->getDeviceSize() * getRenderResolutionScale();
_textureCache.setFrameBufferSize(fbSize);
DependencyManager::get<TextureCache>()->setFrameBufferSize(fbSize);
}
glEnable(GL_LINE_SMOOTH);
@ -711,10 +709,10 @@ void Application::paintGL() {
TV3DManager::display(*whichCamera);
} else {
_glowEffect.prepare();
DependencyManager::get<GlowEffect>()->prepare();
// Viewport is assigned to the size of the framebuffer
QSize size = Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject()->size();
QSize size = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->size();
glViewport(0, 0, size.width(), size.height());
glMatrixMode(GL_MODELVIEW);
@ -730,7 +728,7 @@ void Application::paintGL() {
renderRearViewMirror(_mirrorViewRect);
}
_glowEffect.render();
DependencyManager::get<GlowEffect>()->render();
{
PerformanceTimer perfTimer("renderOverlay");
@ -1921,9 +1919,8 @@ void Application::init() {
_environment.init();
_deferredLightingEffect.init();
_glowEffect.init();
_ambientOcclusionEffect.init();
DependencyManager::get<DeferredLightingEffect>()->init(this);
DependencyManager::get<AmbientOcclusionEffect>()->init(this);
// TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager
_avatarManager.init();
@ -2042,6 +2039,12 @@ void Application::init() {
// save settings when avatar changes
connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings);
// make sure our texture cache knows about window size changes
DependencyManager::get<TextureCache>()->associateWithWidget(getGLWidget());
// initialize the GlowEffect with our widget
DependencyManager::get<GlowEffect>()->init(getGLWidget(), Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect));
}
void Application::closeMirrorView() {
@ -2773,7 +2776,7 @@ glm::vec3 Application::getSunDirection() {
void Application::updateShadowMap() {
PerformanceTimer perfTimer("shadowMap");
QOpenGLFramebufferObject* fbo = _textureCache.getShadowFramebufferObject();
QOpenGLFramebufferObject* fbo = DependencyManager::get<TextureCache>()->getShadowFramebufferObject();
fbo->bind();
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@ -2937,8 +2940,12 @@ void Application::setupWorldLight() {
glMateriali(GL_FRONT, GL_SHININESS, 96);
}
bool Application::shouldRenderMesh(float largestDimension, float distanceToCamera) {
return Menu::getInstance()->shouldRenderMesh(largestDimension, distanceToCamera);
}
QImage Application::renderAvatarBillboard() {
_textureCache.getPrimaryFramebufferObject()->bind();
DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind();
// the "glow" here causes an alpha of one
Glower glower;
@ -2949,7 +2956,7 @@ QImage Application::renderAvatarBillboard() {
QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32);
glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits());
_textureCache.getPrimaryFramebufferObject()->release();
DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->release();
return image;
}
@ -3073,13 +3080,13 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr
glEnable(GL_LIGHTING);
glEnable(GL_DEPTH_TEST);
_deferredLightingEffect.prepare();
DependencyManager::get<DeferredLightingEffect>()->prepare();
if (!selfAvatarOnly) {
// draw a red sphere
float originSphereRadius = 0.05f;
glColor3f(1,0,0);
_geometryCache.renderSphere(originSphereRadius, 15, 15);
DependencyManager::get<GeometryCache>()->renderSphere(originSphereRadius, 15, 15);
// Draw voxels
if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
@ -3116,7 +3123,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr
PerformanceTimer perfTimer("ambientOcclusion");
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... AmbientOcclusion...");
_ambientOcclusionEffect.render();
DependencyManager::get<AmbientOcclusionEffect>()->render();
}
}
@ -3133,7 +3140,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr
{
PROFILE_RANGE("DeferredLighting");
PerformanceTimer perfTimer("lighting");
_deferredLightingEffect.render();
DependencyManager::get<DeferredLightingEffect>()->render();
}
{
@ -3238,6 +3245,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) {
float horizontalScale = _glWidget->getDeviceWidth() / 2.0f;
float verticalScale = _glWidget->getDeviceHeight() / 2.0f;
@ -3300,12 +3315,12 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) {
// set the bounds of rear mirror view
if (billboard) {
QSize size = getTextureCache()->getFrameBufferSize();
QSize size = DependencyManager::get<TextureCache>()->getFrameBufferSize();
glViewport(region.x(), size.height() - region.y() - region.height(), region.width(), region.height());
glScissor(region.x(), size.height() - region.y() - region.height(), region.width(), region.height());
} else {
// if not rendering the billboard, the region is in device independent coordinates; must convert to device
QSize size = getTextureCache()->getFrameBufferSize();
QSize size = DependencyManager::get<TextureCache>()->getFrameBufferSize();
float ratio = QApplication::desktop()->windowHandle()->devicePixelRatio() * getRenderResolutionScale();
int x = region.x() * ratio, y = region.y() * ratio, width = region.width() * ratio, height = region.height() * ratio;
glViewport(x, size.height() - y - height, width, height);
@ -4006,7 +4021,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());
scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());
scriptEngine->registerGlobalObject("AnimationCache", &_animationCache);
scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>());
scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance());
scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance());
scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels);
@ -4368,7 +4383,7 @@ void Application::skipVersion(QString latestVersion) {
void Application::takeSnapshot() {
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->play();

View file

@ -15,6 +15,8 @@
#include <map>
#include <time.h>
#include <gpu/GPUConfig.h>
#include <QApplication>
#include <QMainWindow>
#include <QAction>
@ -32,12 +34,15 @@
#include <EntityCollisionSystem.h>
#include <EntityEditPacketSender.h>
#include <GeometryCache.h>
#include <NetworkPacket.h>
#include <NodeList.h>
#include <OctreeQuery.h>
#include <PacketHeaders.h>
#include <ScriptEngine.h>
#include <OctreeQuery.h>
#include <TextureCache.h>
#include <ViewFrustum.h>
#include <ViewStateInterface.h>
#include <VoxelEditPacketSender.h>
#include "MainWindow.h"
@ -57,11 +62,6 @@
#include "devices/PrioVR.h"
#include "devices/SixenseManager.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 "ui/BandwidthDialog.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_EDIT_ENTITIES_PATH = "html/edit-entities-commands.html";
class Application : public QApplication {
class Application : public QApplication, public ViewStateInterface {
Q_OBJECT
friend class OctreePacketProcessor;
@ -136,7 +136,6 @@ class Application : public QApplication {
public:
static Application* getInstance() { return static_cast<Application*>(QCoreApplication::instance()); }
static QString& resourcesPath();
static const glm::vec3& getPositionForPath() { return getInstance()->_myAvatar->getPosition(); }
static glm::quat getOrientationForPath() { return getInstance()->_myAvatar->getOrientation(); }
@ -233,7 +232,7 @@ public:
const glm::vec3& getViewMatrixTranslation() const { return _viewMatrixTranslation; }
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);
/// if you need to access the application settings, use lockSettings()/unlockSettings()
@ -249,11 +248,6 @@ public:
ToolWindow* getToolWindow() { return _toolWindow ; }
GeometryCache* getGeometryCache() { return &_geometryCache; }
AnimationCache* getAnimationCache() { return &_animationCache; }
TextureCache* getTextureCache() { return &_textureCache; }
DeferredLightingEffect* getDeferredLightingEffect() { return &_deferredLightingEffect; }
GlowEffect* getGlowEffect() { return &_glowEffect; }
ControllerScriptingInterface* getControllerScriptingInterface() { return &_controllerScriptingInterface; }
AvatarManager& getAvatarManager() { return _avatarManager; }
@ -261,7 +255,8 @@ public:
void controlledBroadcastToNodes(const QByteArray& packet, const NodeSet& destinationNodeTypes);
void setupWorldLight();
virtual void setupWorldLight();
virtual bool shouldRenderMesh(float largestDimension, float distanceToCamera);
QImage renderAvatarBillboard();
@ -280,12 +275,17 @@ public:
void getModelViewMatrix(glm::dmat4* modelViewMatrix);
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.
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;
virtual ViewFrustum* getCurrentViewFrustum() { return getDisplayViewFrustum(); }
virtual bool getShadowsEnabled();
virtual bool getCascadeShadowsEnabled();
virtual QThread* getMainThread() { return thread(); }
NodeBounds& getNodeBoundsDisplay() { return _nodeBoundsDisplay; }
FileLogger* getLogger() { return _logger; }
@ -568,15 +568,6 @@ private:
QSet<int> _keysPressed;
GeometryCache _geometryCache;
AnimationCache _animationCache;
TextureCache _textureCache;
DeferredLightingEffect _deferredLightingEffect;
GlowEffect _glowEffect;
AmbientOcclusionEffect _ambientOcclusionEffect;
Audio _audio;
bool _enableProcessVoxelsThread;

View file

@ -37,6 +37,7 @@
#include <AudioInjector.h>
#include <NodeList.h>
#include <PacketHeaders.h>
#include <PathUtils.h>
#include <SharedUtil.h>
#include <StDev.h>
#include <UUID.h>
@ -140,9 +141,9 @@ Audio::Audio(QObject* parent) :
}
void Audio::init(QGLWidget *parent) {
_micTextureId = parent->bindTexture(QImage(Application::resourcesPath() + "images/mic.svg"));
_muteTextureId = parent->bindTexture(QImage(Application::resourcesPath() + "images/mic-mute.svg"));
_boxTextureId = parent->bindTexture(QImage(Application::resourcesPath() + "images/audio-box.svg"));
_micTextureId = parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/mic.svg"));
_muteTextureId = parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/mic-mute.svg"));
_boxTextureId = parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/audio-box.svg"));
}
void Audio::reset() {
@ -450,7 +451,9 @@ void Audio::start() {
qDebug() << "Unable to set up audio output because of a problem with output format.";
}
_inputFrameBuffer.initialize( _inputFormat.channelCount(), _audioInput->bufferSize() * 8 );
if (_audioInput) {
_inputFrameBuffer.initialize( _inputFormat.channelCount(), _audioInput->bufferSize() * 8 );
}
_inputGain.initialize();
_sourceGain.initialize();
_noiseSource.initialize();
@ -1935,6 +1938,9 @@ int Audio::calculateNumberOfFrameSamples(int numBytes) const {
}
float Audio::getAudioOutputMsecsUnplayed() const {
if (!_audioOutput) {
return 0.0f;
}
int bytesAudioOutputUnplayed = _audioOutput->bufferSize() - _audioOutput->bytesFree();
float msecsAudioOutputUnplayed = bytesAudioOutputUnplayed / (float)_outputFormat.bytesForDuration(USECS_PER_MSEC);
return msecsAudioOutputUnplayed;

View file

@ -17,11 +17,12 @@
#include <GeometryUtil.h>
#include <PacketHeaders.h>
#include <PathUtils.h>
#include <ProgramObject.h>
#include <SharedUtil.h>
#include "Application.h"
#include "Camera.h"
#include "renderer/ProgramObject.h"
#include "world.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* 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::Fragment, prefix + ".frag");
program->link();
@ -261,7 +262,7 @@ void Environment::renderAtmosphere(Camera& camera, const EnvironmentData& data)
glDepthMask(GL_FALSE);
glDisable(GL_DEPTH_TEST);
Application::getInstance()->getGeometryCache()->renderSphere(1.0f, 100, 50); //Draw a unit sphere
DependencyManager::get<GeometryCache>()->renderSphere(1.0f, 100, 50); //Draw a unit sphere
glDepthMask(GL_TRUE);
program->release();

View file

@ -32,6 +32,8 @@
#include <AccountManager.h>
#include <AddressManager.h>
#include <DependencyManager.h>
#include <GlowEffect.h>
#include <PathUtils.h>
#include <UUID.h>
#include <UserActivityLogger.h>
#include <XmppClient.h>
@ -54,7 +56,6 @@
#include "ui/LoginDialog.h"
#include "ui/NodeBounds.h"
Menu* Menu::_instance = NULL;
Menu* Menu::getInstance() {
@ -246,7 +247,7 @@ Menu::Menu() :
connect(&xmppClient, &QXmppClient::connected, this, &Menu::toggleChat);
connect(&xmppClient, &QXmppClient::disconnected, this, &Menu::toggleChat);
QDir::setCurrent(Application::resourcesPath());
QDir::setCurrent(PathUtils::resourcesPath());
// init chat window to listen chat
_chatWindow = new ChatWindow(Application::getInstance()->getWindow());
#endif
@ -424,7 +425,8 @@ Menu::Menu() :
true,
appInstance,
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);
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 Console = "Console...";
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 DontDoPrecisionPicking = "Don't Do Precision Picking";
const QString DecreaseAvatarSize = "Decrease Avatar Size";

View file

@ -21,17 +21,18 @@
#include <glm/gtx/transform.hpp>
#include <DeferredLightingEffect.h>
#include <GeometryUtil.h>
#include <Model.h>
#include <SharedUtil.h>
#include <MetavoxelMessages.h>
#include <MetavoxelUtil.h>
#include <PathUtils.h>
#include <ScriptCache.h>
#include "Application.h"
#include "MetavoxelSystem.h"
#include "renderer/Model.h"
#include "renderer/RenderUtil.h"
REGISTER_META_OBJECT(DefaultMetavoxelRendererImplementation)
REGISTER_META_OBJECT(SphereRenderer)
@ -63,9 +64,9 @@ void MetavoxelSystem::init() {
_voxelBufferAttribute->setLODThresholdMultiplier(
AttributeRegistry::getInstance()->getVoxelColorAttribute()->getLODThresholdMultiplier());
_baseHeightfieldProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() +
_baseHeightfieldProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() +
"shaders/metavoxel_heightfield_base.vert");
_baseHeightfieldProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() +
_baseHeightfieldProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() +
"shaders/metavoxel_heightfield_base.frag");
_baseHeightfieldProgram.link();
@ -78,9 +79,9 @@ void MetavoxelSystem::init() {
loadSplatProgram("heightfield", _splatHeightfieldProgram, _splatHeightfieldLocations);
_heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() +
_heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() +
"shaders/metavoxel_heightfield_cursor.vert");
_heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() +
_heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() +
"shaders/metavoxel_cursor.frag");
_heightfieldCursorProgram.link();
@ -88,17 +89,17 @@ void MetavoxelSystem::init() {
_heightfieldCursorProgram.setUniformValue("heightMap", 0);
_heightfieldCursorProgram.release();
_baseVoxelProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() +
_baseVoxelProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() +
"shaders/metavoxel_voxel_base.vert");
_baseVoxelProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() +
_baseVoxelProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() +
"shaders/metavoxel_voxel_base.frag");
_baseVoxelProgram.link();
loadSplatProgram("voxel", _splatVoxelProgram, _splatVoxelLocations);
_voxelCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() +
_voxelCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() +
"shaders/metavoxel_voxel_cursor.vert");
_voxelCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() +
_voxelCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() +
"shaders/metavoxel_cursor.frag");
_voxelCursorProgram.link();
}
@ -205,7 +206,7 @@ void MetavoxelSystem::render() {
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, true);
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, true);
glDisable(GL_BLEND);
glEnable(GL_CULL_FACE);
@ -251,7 +252,7 @@ void MetavoxelSystem::render() {
glPopMatrix();
}
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, false);
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, false);
_baseHeightfieldProgram.release();
@ -348,7 +349,7 @@ void MetavoxelSystem::render() {
}
if (!_voxelBaseBatches.isEmpty()) {
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, true);
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, true);
glEnableClientState(GL_VERTEX_ARRAY);
glDisable(GL_BLEND);
@ -383,7 +384,7 @@ void MetavoxelSystem::render() {
glDisable(GL_ALPHA_TEST);
glEnable(GL_BLEND);
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, false);
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, false);
if (!_voxelSplatBatches.isEmpty()) {
glDepthFunc(GL_LEQUAL);
@ -463,14 +464,14 @@ void MetavoxelSystem::render() {
}
if (!_hermiteBatches.isEmpty() && Menu::getInstance()->isOptionChecked(MenuOption::DisplayHermiteData)) {
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, true);
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, true);
glEnableClientState(GL_VERTEX_ARRAY);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glNormal3f(0.0f, 1.0f, 0.0f);
Application::getInstance()->getDeferredLightingEffect()->bindSimpleProgram();
DependencyManager::get<DeferredLightingEffect>()->bindSimpleProgram();
foreach (const HermiteBatch& batch, _hermiteBatches) {
batch.vertexBuffer->bind();
@ -482,11 +483,11 @@ void MetavoxelSystem::render() {
batch.vertexBuffer->release();
}
Application::getInstance()->getDeferredLightingEffect()->releaseSimpleProgram();
DependencyManager::get<DeferredLightingEffect>()->releaseSimpleProgram();
glDisableClientState(GL_VERTEX_ARRAY);
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, false);
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, false);
}
_hermiteBatches.clear();
@ -797,7 +798,7 @@ void MetavoxelSystem::applyMaterialEdit(const MetavoxelEditMessage& message, boo
Q_ARG(bool, reliable));
return;
}
QSharedPointer<NetworkTexture> texture = Application::getInstance()->getTextureCache()->getTexture(
QSharedPointer<NetworkTexture> texture = DependencyManager::get<TextureCache>()->getTexture(
material->getDiffuse(), SPLAT_TEXTURE);
if (texture->isLoaded()) {
MetavoxelEditMessage newMessage = message;
@ -836,9 +837,9 @@ void MetavoxelSystem::guideToAugmented(MetavoxelVisitor& visitor, bool render) {
}
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");
program.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() +
program.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() +
"shaders/metavoxel_" + type + "_splat.frag");
program.link();
@ -1177,10 +1178,11 @@ void VoxelBuffer::render(bool cursor) {
if (!_materials.isEmpty()) {
_networkTextures.resize(_materials.size());
TextureCache* textureCache = DependencyManager::get<TextureCache>();
for (int i = 0; i < _materials.size(); i++) {
const SharedObjectPointer material = _materials.at(i);
if (material) {
_networkTextures[i] = Application::getInstance()->getTextureCache()->getTexture(
_networkTextures[i] = textureCache->getTexture(
static_cast<MaterialObject*>(material.data())->getDiffuse(), SPLAT_TEXTURE);
}
}
@ -1980,7 +1982,7 @@ void SphereRenderer::render(const MetavoxelLOD& lod, bool contained, bool cursor
glm::vec3 axis = glm::axis(rotation);
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();
}
@ -2001,7 +2003,7 @@ void CuboidRenderer::render(const MetavoxelLOD& lod, bool contained, bool cursor
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
glScalef(1.0f, cuboid->getAspectY(), cuboid->getAspectZ());
Application::getInstance()->getDeferredLightingEffect()->renderSolidCube(cuboid->getScale() * 2.0f);
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(cuboid->getScale() * 2.0f);
glPopMatrix();
}
@ -2231,10 +2233,11 @@ void HeightfieldNodeRenderer::render(const HeightfieldNodePointer& node, const g
const QVector<SharedObjectPointer>& materials = node->getMaterial()->getMaterials();
_networkTextures.resize(materials.size());
TextureCache* textureCache = DependencyManager::get<TextureCache>();
for (int i = 0; i < materials.size(); i++) {
const SharedObjectPointer& material = materials.at(i);
if (material) {
_networkTextures[i] = Application::getInstance()->getTextureCache()->getTexture(
_networkTextures[i] = textureCache->getTexture(
static_cast<MaterialObject*>(material.data())->getDiffuse(), SPLAT_TEXTURE);
}
}

View file

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

View file

@ -466,17 +466,19 @@ void ModelUploader::processCheck() {
_timer.stop();
switch (reply->error()) {
case QNetworkReply::NoError:
case QNetworkReply::NoError: {
QMessageBox::information(NULL,
QString("ModelUploader::processCheck()"),
QString("Your model is now available in the browser."),
QMessageBox::Ok);
Application::getInstance()->getGeometryCache()->refresh(_url);
DependencyManager::get<GeometryCache>()->refresh(_url);
TextureCache* textureCache = DependencyManager::get<TextureCache>();
foreach (const QByteArray& filename, _textureFilenames) {
Application::getInstance()->getTextureCache()->refresh(_textureBase + filename);
textureCache->refresh(_textureBase + filename);
}
deleteLater();
break;
}
case QNetworkReply::ContentNotFoundError:
if (--_numberOfChecks) {
_timer.start(TIMEOUT);

View file

@ -71,22 +71,23 @@ void renderWorldBox() {
glPushMatrix();
glTranslatef(MARKER_DISTANCE, 0, 0);
glColor3fv(red);
Application::getInstance()->getGeometryCache()->renderSphere(MARKER_RADIUS, 10, 10);
GeometryCache* geometryCache = DependencyManager::get<GeometryCache>();
geometryCache->renderSphere(MARKER_RADIUS, 10, 10);
glPopMatrix();
glPushMatrix();
glTranslatef(0, MARKER_DISTANCE, 0);
glColor3fv(green);
Application::getInstance()->getGeometryCache()->renderSphere(MARKER_RADIUS, 10, 10);
geometryCache->renderSphere(MARKER_RADIUS, 10, 10);
glPopMatrix();
glPushMatrix();
glTranslatef(0, 0, MARKER_DISTANCE);
glColor3fv(blue);
Application::getInstance()->getGeometryCache()->renderSphere(MARKER_RADIUS, 10, 10);
geometryCache->renderSphere(MARKER_RADIUS, 10, 10);
glPopMatrix();
glPushMatrix();
glColor3fv(gray);
glTranslatef(MARKER_DISTANCE, 0, MARKER_DISTANCE);
Application::getInstance()->getGeometryCache()->renderSphere(MARKER_RADIUS, 10, 10);
geometryCache->renderSphere(MARKER_RADIUS, 10, 10);
glPopMatrix();
}

View file

@ -11,6 +11,8 @@
#include <vector>
#include <gpu/GPUConfig.h>
#include <QDesktopWidget>
#include <QWindow>
@ -20,11 +22,15 @@
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtx/vector_query.hpp>
#include <DeferredLightingEffect.h>
#include <GeometryUtil.h>
#include <GlowEffect.h>
#include <NodeList.h>
#include <PacketHeaders.h>
#include <PathUtils.h>
#include <PerfStat.h>
#include <SharedUtil.h>
#include <TextureCache.h>
#include "Application.h"
#include "Avatar.h"
@ -36,7 +42,6 @@
#include "Recorder.h"
#include "world.h"
#include "devices/OculusManager.h"
#include "renderer/TextureCache.h"
#include "ui/TextRenderer.h"
using namespace std;
@ -360,7 +365,7 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode, bool
glm::quat orientation = getOrientation();
foreach (const AvatarManager::LocalLight& light, Application::getInstance()->getAvatarManager().getLocalLights()) {
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,
LIGHT_EXPONENT, LIGHT_CUTOFF);
}
@ -394,7 +399,7 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode, bool
} else {
glTranslatef(_position.x, getDisplayNamePosition().y + LOOK_AT_INDICATOR_OFFSET, _position.z);
}
Application::getInstance()->getGeometryCache()->renderSphere(LOOK_AT_INDICATOR_RADIUS, 15, 15);
DependencyManager::get<GeometryCache>()->renderSphere(LOOK_AT_INDICATOR_RADIUS, 15, 15);
glPopMatrix();
}
}
@ -422,7 +427,7 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode, bool
glPushMatrix();
glTranslatef(_position.x, _position.y, _position.z);
glScalef(height, height, height);
Application::getInstance()->getGeometryCache()->renderSphere(sphereRadius, 15, 15);
DependencyManager::get<GeometryCache>()->renderSphere(sphereRadius, 15, 15);
glPopMatrix();
}
@ -913,13 +918,13 @@ void Avatar::scaleVectorRelativeToPosition(glm::vec3 &positionToScale) const {
void Avatar::setFaceModelURL(const QUrl& 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());
}
void Avatar::setSkeletonModelURL(const QUrl& 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());
}

View file

@ -15,16 +15,17 @@
#include <glm/gtx/string_cast.hpp>
#include <GlowEffect.h>
#include <PerfStat.h>
#include <RegisteredMetaTypes.h>
#include <UUID.h>
#include "Application.h"
#include "Avatar.h"
#include "AvatarManager.h"
#include "Menu.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.
const QUuid MY_AVATAR_KEY; // NULL key

View file

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

View file

@ -8,18 +8,20 @@
// 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 <NodeList.h>
#include <GeometryUtil.h>
#include <ProgramObject.h>
#include "Application.h"
#include "Avatar.h"
#include "Hand.h"
#include "Menu.h"
#include "Util.h"
#include "renderer/ProgramObject.h"
using namespace std;
@ -114,7 +116,7 @@ void Hand::render(bool isMine, Model::RenderMode renderMode) {
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
glColor3f(0.0f, 1.0f, 0.0f);
Application::getInstance()->getGeometryCache()->renderSphere(PALM_COLLISION_RADIUS * _owningAvatar->getScale(), 10, 10);
DependencyManager::get<GeometryCache>()->renderSphere(PALM_COLLISION_RADIUS * _owningAvatar->getScale(), 10, 10);
glPopMatrix();
}
}
@ -179,7 +181,7 @@ void Hand::renderHandTargets(bool isMine) {
Avatar::renderJointConnectingCone(root, offsetFromPalm, PALM_DISK_RADIUS, 0.0f);
glPushMatrix();
glTranslatef(root.x, root.y, root.z);
Application::getInstance()->getGeometryCache()->renderSphere(PALM_BALL_RADIUS, 20.0f, 20.0f);
DependencyManager::get<GeometryCache>()->renderSphere(PALM_BALL_RADIUS, 20.0f, 20.0f);
glPopMatrix();
}
}

View file

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

View file

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

View file

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

View file

@ -22,6 +22,7 @@
#include <AccountManager.h>
#include <AddressManager.h>
#include <AnimationHandle.h>
#include <DependencyManager.h>
#include <GeometryUtil.h>
#include <NodeList.h>
@ -40,7 +41,6 @@
#include "Recorder.h"
#include "devices/Faceshift.h"
#include "devices/OculusManager.h"
#include "renderer/AnimationHandle.h"
#include "ui/TextRenderer.h"
using namespace std;
@ -394,7 +394,7 @@ void MyAvatar::renderDebugBodyPoints() {
glPushMatrix();
glColor4f(0, 1, 0, .5f);
glTranslatef(position.x, position.y, position.z);
Application::getInstance()->getGeometryCache()->renderSphere(0.2f, 10.0f, 10.0f);
DependencyManager::get<GeometryCache>()->renderSphere(0.2f, 10.0f, 10.0f);
glPopMatrix();
// Head Sphere
@ -402,7 +402,7 @@ void MyAvatar::renderDebugBodyPoints() {
glPushMatrix();
glColor4f(0, 1, 0, .5f);
glTranslatef(position.x, position.y, position.z);
Application::getInstance()->getGeometryCache()->renderSphere(0.15f, 10.0f, 10.0f);
DependencyManager::get<GeometryCache>()->renderSphere(0.15f, 10.0f, 10.0f);
glPopMatrix();
}

View file

@ -554,6 +554,7 @@ void SkeletonModel::renderRagdoll() {
float radius1 = 0.008f;
float radius2 = 0.01f;
glm::vec3 simulationTranslation = _ragdoll->getTranslationInSimulationFrame();
GeometryCache* geometryCache = DependencyManager::get<GeometryCache>();
for (int i = 0; i < numPoints; ++i) {
glPushMatrix();
// NOTE: ragdollPoints are in simulation-frame but we want them to be model-relative
@ -561,9 +562,9 @@ void SkeletonModel::renderRagdoll() {
glTranslatef(position.x, position.y, position.z);
// draw each point as a yellow hexagon with black border
glColor4f(0.0f, 0.0f, 0.0f, alpha);
Application::getInstance()->getGeometryCache()->renderSphere(radius2, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
geometryCache->renderSphere(radius2, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
glColor4f(1.0f, 1.0f, 0.0f, alpha);
Application::getInstance()->getGeometryCache()->renderSphere(radius1, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
geometryCache->renderSphere(radius1, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
glPopMatrix();
}
glPopMatrix();
@ -913,7 +914,8 @@ void SkeletonModel::renderBoundingCollisionShapes(float alpha) {
endPoint = endPoint - _translation;
glTranslatef(endPoint.x, endPoint.y, endPoint.z);
glColor4f(0.6f, 0.6f, 0.8f, alpha);
Application::getInstance()->getGeometryCache()->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
GeometryCache* geometryCache = DependencyManager::get<GeometryCache>();
geometryCache->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
// draw a yellow sphere at the capsule startpoint
glm::vec3 startPoint;
@ -922,7 +924,7 @@ void SkeletonModel::renderBoundingCollisionShapes(float alpha) {
glm::vec3 axis = endPoint - startPoint;
glTranslatef(-axis.x, -axis.y, -axis.z);
glColor4f(0.8f, 0.8f, 0.6f, alpha);
Application::getInstance()->getGeometryCache()->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
geometryCache->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
// draw a green cylinder between the two points
glm::vec3 origin(0.0f);
@ -948,6 +950,8 @@ void SkeletonModel::renderJointCollisionShapes(float alpha) {
continue;
}
GeometryCache* geometryCache = DependencyManager::get<GeometryCache>();
glPushMatrix();
// shapes are stored in simulation-frame but we want position to be model-relative
if (shape->getType() == SPHERE_SHAPE) {
@ -955,7 +959,7 @@ void SkeletonModel::renderJointCollisionShapes(float alpha) {
glTranslatef(position.x, position.y, position.z);
// draw a grey sphere at shape position
glColor4f(0.75f, 0.75f, 0.75f, alpha);
Application::getInstance()->getGeometryCache()->renderSphere(shape->getBoundingRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
geometryCache->renderSphere(shape->getBoundingRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
} else if (shape->getType() == CAPSULE_SHAPE) {
CapsuleShape* capsule = static_cast<CapsuleShape*>(shape);
@ -965,7 +969,7 @@ void SkeletonModel::renderJointCollisionShapes(float alpha) {
endPoint = endPoint - simulationTranslation;
glTranslatef(endPoint.x, endPoint.y, endPoint.z);
glColor4f(0.6f, 0.6f, 0.8f, alpha);
Application::getInstance()->getGeometryCache()->renderSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
geometryCache->renderSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
// draw a yellow sphere at the capsule startpoint
glm::vec3 startPoint;
@ -974,7 +978,7 @@ void SkeletonModel::renderJointCollisionShapes(float alpha) {
glm::vec3 axis = endPoint - startPoint;
glTranslatef(-axis.x, -axis.y, -axis.z);
glColor4f(0.8f, 0.8f, 0.6f, alpha);
Application::getInstance()->getGeometryCache()->renderSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
geometryCache->renderSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
// draw a green cylinder between the two points
glm::vec3 origin(0.0f);

View file

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

View file

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

View file

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

View file

@ -21,6 +21,8 @@
#include <glm/glm.hpp>
#include <GlowEffect.h>
#include <PathUtils.h>
#include <SharedUtil.h>
#include <UserActivityLogger.h>
@ -136,8 +138,8 @@ void OculusManager::connect() {
if (!_programInitialized) {
// Shader program
_programInitialized = true;
_program.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + "shaders/oculus.vert");
_program.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/oculus.frag");
_program.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/oculus.vert");
_program.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/oculus.frag");
_program.link();
// Uniforms
@ -447,9 +449,9 @@ 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
if (Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect)) {
Application::getInstance()->getGlowEffect()->prepare();
DependencyManager::get<GlowEffect>()->prepare();
} else {
Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject()->bind();
DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
@ -552,11 +554,11 @@ 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
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());
} else {
Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject()->release();
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject()->texture());
DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->release();
glBindTexture(GL_TEXTURE_2D, DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->texture());
}
// restore our normal viewport

View file

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

View file

@ -15,6 +15,8 @@
#include <glm/glm.hpp>
#include <GlowEffect.h>
#include "Application.h"
#include "TV3DManager.h"
@ -103,7 +105,7 @@ void TV3DManager::display(Camera& whichCamera) {
applicationOverlay.renderOverlay(true);
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);
@ -169,7 +171,7 @@ void TV3DManager::display(Camera& whichCamera) {
// reset the viewport to how we started
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,

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -15,6 +15,8 @@
#include "InterfaceConfig.h"
#include <DependencyManager.h>
#include <DeferredLightingEffect.h>
#include <PerfStat.h>
#include <SphereEntityItem.h>
@ -23,7 +25,6 @@
#include "EntityTreeRenderer.h"
#include "RenderableSphereEntityItem.h"
EntityItem* RenderableSphereEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return new RenderableSphereEntityItem(entityID, properties);
}
@ -51,7 +52,7 @@ void RenderableSphereEntityItem::render(RenderArgs* args) {
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.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();
};

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???
if (_editDialog) {
if (_nonBlockingFormActive) {
qDebug() << "Show Non-Blocking Form called when form already active.";
return;
}

View file

@ -13,7 +13,6 @@
#define hifi_Config_h
#include "InterfaceConfig.h"
#include "renderer/ProgramObject.h"
#include <cstddef>
#include <cfloat>
@ -35,6 +34,8 @@
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/matrix_access.hpp>
#include <ProgramObject.h>
#include "AngleUtil.h"
#include "Radix2InplaceSort.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
//
#include <PathUtils.h>
#include "AddressBarDialog.h"
#include "AddressManager.h"
#include "Application.h"
@ -82,7 +84,7 @@ void AddressBarDialog::setupUI() {
_goButton->setSizePolicy(sizePolicy);
_goButton->setMinimumSize(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->setDefault(true);
_goButton->setFlat(true);
@ -99,7 +101,7 @@ void AddressBarDialog::setupUI() {
_closeButton->setSizePolicy(sizePolicy);
_closeButton->setMinimumSize(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->setIconSize(QSize(CLOSE_BUTTON_SIZE, CLOSE_BUTTON_SIZE));
_closeButton->setFlat(true);
@ -112,7 +114,7 @@ void AddressBarDialog::setupUI() {
}
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->setFocus();
FramelessDialog::showEvent(event);
@ -120,7 +122,7 @@ void AddressBarDialog::showEvent(QShowEvent* event) {
void AddressBarDialog::accept() {
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();
connect(&addressManager, &AddressManager::lookupResultsFinished, this, &QDialog::hide);
addressManager.handleLookupString(_addressLineEdit->text());

View file

@ -12,6 +12,8 @@
#include "InterfaceConfig.h"
#include <QOpenGLFramebufferObject>
#include <PathUtils.h>
#include <PerfStat.h>
#include "Application.h"
@ -379,7 +381,7 @@ void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float as
glEnd();
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
@ -513,7 +515,7 @@ void ApplicationOverlay::renderPointers() {
//lazily load crosshair texture
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);

View file

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

View file

@ -12,6 +12,8 @@
#include <QScreen>
#include <QWindow>
#include <PathUtils.h>
#include "Application.h"
#include "FramelessDialog.h"
#include "Menu.h"
@ -80,10 +82,10 @@ bool FramelessDialog::eventFilter(QObject* sender, QEvent* event) {
}
void FramelessDialog::setStyleSheetFile(const QString& fileName) {
QFile globalStyleSheet(Application::resourcesPath() + "styles/global.qss");
QFile styleSheet(Application::resourcesPath() + fileName);
QFile globalStyleSheet(PathUtils::resourcesPath() + "styles/global.qss");
QFile styleSheet(PathUtils::resourcesPath() + fileName);
if (styleSheet.open(QIODevice::ReadOnly) && globalStyleSheet.open(QIODevice::ReadOnly) ) {
QDir::setCurrent(Application::resourcesPath());
QDir::setCurrent(PathUtils::resourcesPath());
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
//
#include "InfoView.h"
#include <QApplication>
#include "Application.h"
#include <QtWebKitWidgets/QWebFrame>
#include <QtWebKit/QWebElement>
#include <QDesktopWidget>
#include <PathUtils.h>
#include "Application.h"
#include "InfoView.h"
#define SETTINGS_VERSION_KEY "info-version"
#define MAX_DIALOG_HEIGHT_RATIO 0.9
@ -25,7 +28,7 @@ InfoView::InfoView(bool forced, QString path) :
{
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);
load(url);

View file

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

View file

@ -15,10 +15,10 @@
#include <QTextBlock>
#include <QtGui>
#include <PathUtils.h>
#include <SharedUtil.h>
#include "Application.h"
#include "ui/LogDialog.h"
const int TOP_BAR_HEIGHT = 46;
@ -44,9 +44,9 @@ LogDialog::LogDialog(QWidget* parent, AbstractLoggerInterface* logger) : QDialog
setWindowTitle("Log");
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)) {
QDir::setCurrent(Application::resourcesPath());
QDir::setCurrent(PathUtils::resourcesPath());
setStyleSheet(styleSheet.readAll());
}

View file

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

View file

@ -35,6 +35,7 @@
#include <AttributeRegistry.h>
#include <MetavoxelMessages.h>
#include <MetavoxelUtil.h>
#include <PathUtils.h>
#include "Application.h"
#include "MetavoxelEditor.h"
@ -145,7 +146,7 @@ MetavoxelEditor::MetavoxelEditor() :
return;
}
_gridProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/grid.frag");
_gridProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/grid.frag");
_gridProgram.link();
}
@ -353,7 +354,7 @@ void MetavoxelEditor::render() {
_gridProgram.bind();
Application::getInstance()->getGeometryCache()->renderGrid(GRID_DIVISIONS, GRID_DIVISIONS);
DependencyManager::get<GeometryCache>()->renderGrid(GRID_DIVISIONS, GRID_DIVISIONS);
_gridProgram.release();
@ -916,7 +917,7 @@ void MaterialControl::updateTexture() {
_texture.clear();
return;
}
_texture = Application::getInstance()->getTextureCache()->getTexture(material->getDiffuse(), SPLAT_TEXTURE);
_texture = DependencyManager::get<TextureCache>()->getTexture(material->getDiffuse(), SPLAT_TEXTURE);
if (_texture) {
if (_texture->isLoaded()) {
textureLoaded();

View file

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

View file

@ -13,12 +13,13 @@
#include <QMouseEvent>
#include <PathUtils.h>
#include <SharedUtil.h>
#include "Application.h"
#include "RearMirrorTools.h"
#include "Util.h"
#include "RearMirrorTools.h"
const char SETTINGS_GROUP_NAME[] = "Rear View Tools";
const char ZOOM_LEVEL_SETTINGS[] = "ZoomLevel";
@ -32,13 +33,13 @@ RearMirrorTools::RearMirrorTools(QGLWidget* parent, QRect& bounds, QSettings* se
_fullScreen(false)
{
_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
// _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"));
_zoomBodyTextureId = _parent->bindTexture(QImage(Application::resourcesPath() + "images/minus.svg"));
_zoomHeadTextureId = _parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/plus.svg"));
_zoomBodyTextureId = _parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/minus.svg"));
_shrinkIconRect = QRect(ICON_PADDING, 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 <QWindow>
#include <PathUtils.h>
#include "Application.h"
#include "Menu.h"
#include "ScriptsModel.h"
@ -109,7 +111,7 @@ void RunningScriptsWidget::setRunningScripts(const QStringList& list) {
QPushButton* closeButton = new QPushButton(row);
closeButton->setFlat(true);
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->setStyleSheet("border: 0;");
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
//
#include "Application.h" // HACK ATTACK WARNING: for windows build to work, we need this ahead of QtGui
#include <gpu/GPUConfig.h>
#include <QtGui>
#include "ui_updateDialog.h"
#include "Application.h"
#include "UpdateDialog.h"

View file

@ -18,6 +18,8 @@
#include <QJsonArray>
#include <QJsonObject>
#include <PathUtils.h>
#include "Application.h"
#include "VoxelImportDialog.h"
@ -64,7 +66,7 @@ QIcon HiFiIconProvider::icon(QFileIconProvider::IconType type) const {
break;
}
return QIcon(Application::resourcesPath() + "icons/" + typeString + ".svg");
return QIcon(PathUtils::resourcesPath() + "icons/" + typeString + ".svg");
}
QIcon HiFiIconProvider::icon(const QFileInfo &info) const {
@ -72,21 +74,21 @@ QIcon HiFiIconProvider::icon(const QFileInfo &info) const {
if (info.isDir()) {
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)) {
return QIcon(Application::resourcesPath() + "icons/desktop.svg");
return QIcon(PathUtils::resourcesPath() + "icons/desktop.svg");
} 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()) {
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 {
@ -307,16 +309,16 @@ void VoxelImportDialog::setLayout() {
widget = findChild<QWidget*>("treeView");
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)) {
QDir::setCurrent(Application::resourcesPath());
QDir::setCurrent(PathUtils::resourcesPath());
setStyleSheet(styleSheet.readAll());
}
}
void VoxelImportDialog::setImportTypes() {
QFile config(Application::resourcesPath() + "config/config.json");
QFile config(PathUtils::resourcesPath() + "config/config.json");
config.open(QFile::ReadOnly | QFile::Text);
QJsonDocument document = QJsonDocument::fromJson(config.readAll());
if (!document.isNull() && !document.isEmpty()) {

View file

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

View file

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

View file

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

View file

@ -9,9 +9,10 @@
// 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 "Grid3DOverlay.h"
ProgramObject Grid3DOverlay::_gridProgram;
@ -36,7 +37,7 @@ void Grid3DOverlay::render(RenderArgs* args) {
}
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();
return;
}
@ -87,7 +88,7 @@ void Grid3DOverlay::render(RenderArgs* args) {
float scale = MINOR_GRID_DIVISIONS * spacing;
glScalef(scale, scale, scale);
Application::getInstance()->getGeometryCache()->renderGrid(MINOR_GRID_DIVISIONS, MINOR_GRID_DIVISIONS);
DependencyManager::get<GeometryCache>()->renderGrid(MINOR_GRID_DIVISIONS, MINOR_GRID_DIVISIONS);
}
glPopMatrix();
@ -102,7 +103,7 @@ void Grid3DOverlay::render(RenderArgs* args) {
float scale = MAJOR_GRID_DIVISIONS * spacing;
glScalef(scale, scale, scale);
Application::getInstance()->getGeometryCache()->renderGrid(MAJOR_GRID_DIVISIONS, MAJOR_GRID_DIVISIONS);
DependencyManager::get<GeometryCache>()->renderGrid(MAJOR_GRID_DIVISIONS, MAJOR_GRID_DIVISIONS);
}
glPopMatrix();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -9,24 +9,25 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include <cstring>
#include <cmath>
#include <iostream> // to load voxels from file
#include <fstream> // to load voxels from file
#include <gpu/GPUConfig.h>
#include <OctalCode.h>
#include <PacketHeaders.h>
#include <PathUtils.h>
#include <PerfStat.h>
#include <ProgramObject.h>
#include <SharedUtil.h>
#include <NodeList.h>
#include <glm/gtc/type_ptr.hpp>
#include "Application.h"
#include "InterfaceConfig.h"
#include "Menu.h"
#include "renderer/ProgramObject.h"
#include "VoxelConstants.h"
#include "VoxelSystem.h"
@ -372,9 +373,9 @@ void VoxelSystem::initVoxelMemory() {
// create our simple fragment shader if we're the first system to init
if (!_program.isLinked()) {
_program.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/voxel.vert");
PathUtils::resourcesPath() + "shaders/voxel.vert");
_program.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/voxel.frag");
PathUtils::resourcesPath() + "shaders/voxel.frag");
_program.link();
}
_initialized = true;
@ -1171,7 +1172,7 @@ void VoxelSystem::render() {
void VoxelSystem::applyScaleAndBindProgram(bool texture) {
if (texture) {
bindPerlinModulateProgram();
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPermutationNormalTextureID());
glBindTexture(GL_TEXTURE_2D, DependencyManager::get<TextureCache>()->getPermutationNormalTextureID());
} else {
_program.bind();
}
@ -1179,7 +1180,7 @@ void VoxelSystem::applyScaleAndBindProgram(bool texture) {
glPushMatrix();
glScalef(_treeScale, _treeScale, _treeScale);
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, true);
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, true);
}
void VoxelSystem::removeScaleAndReleaseProgram(bool texture) {
@ -1193,7 +1194,7 @@ void VoxelSystem::removeScaleAndReleaseProgram(bool texture) {
_program.release();
}
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, false);
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, false);
}
int VoxelSystem::_nodeCount = 0;
@ -1645,9 +1646,9 @@ unsigned long VoxelSystem::getVoxelMemoryUsageGPU() {
void VoxelSystem::bindPerlinModulateProgram() {
if (!_perlinModulateProgram.isLinked()) {
_perlinModulateProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/perlin_modulate.vert");
PathUtils::resourcesPath() + "shaders/perlin_modulate.vert");
_perlinModulateProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/perlin_modulate.frag");
PathUtils::resourcesPath() + "shaders/perlin_modulate.frag");
_perlinModulateProgram.link();
_perlinModulateProgram.bind();

View file

@ -15,30 +15,31 @@
#include <QScriptEngine>
#include <QScriptValue>
#include <ResourceCache.h>
#include <DependencyManager.h>
#include <FBXReader.h>
#include <ResourceCache.h>
class Animation;
typedef QSharedPointer<Animation> AnimationPointer;
/// Scriptable interface for FBX animation loading.
class AnimationCache : public ResourceCache {
class AnimationCache : public ResourceCache, public DependencyManager::Dependency {
Q_OBJECT
public:
AnimationCache(QObject* parent = NULL);
Q_INVOKABLE AnimationPointer getAnimation(const QString& url) { return getAnimation(QUrl(url)); }
Q_INVOKABLE AnimationPointer getAnimation(const QUrl& url);
protected:
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)

View file

@ -62,7 +62,7 @@ public:
float getNextOutputFrameLoudness() const;
int samplesAvailable() const;
int framesAvailable() const { return samplesAvailable() / _numFrameSamples; }
int framesAvailable() const { return (_numFrameSamples == 0) ? 0 : samplesAvailable() / _numFrameSamples; }
int getNumFrameSamples() const { return _numFrameSamples; }

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)
AnimationCache ModelEntityItem::_animationCache;
// This class/instance will cleanup the animations once unloaded.
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 (_loadedAnimations.find(url) == _loadedAnimations.end()) {
animation = _animationCache.getAnimation(url);
animation = DependencyManager::get<AnimationCache>()->getAnimation(url);
_loadedAnimations[url] = animation;
} else {
animation = _loadedAnimations[url];

View file

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

View file

@ -28,9 +28,13 @@ ResourceCache::ResourceCache(QObject* parent) :
}
ResourceCache::~ResourceCache() {
// make sure our unused resources know we're out of commission
foreach (const QSharedPointer<Resource>& resource, _unusedResources) {
resource->setCache(NULL);
// the unused resources may themselves reference resources that will be added to the unused
// list on destruction, so keep clearing until there are no references left
while (!_unusedResources.isEmpty()) {
foreach (const QSharedPointer<Resource>& resource, _unusedResources) {
resource->setCache(NULL);
}
_unusedResources.clear();
}
}

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 "InterfaceConfig.h"
#include <gpu/GPUConfig.h>
#include <QOpenGLFramebufferObject>
#include <glm/gtc/random.hpp>
#include <PathUtils.h>
#include <SharedUtil.h>
#include "Application.h"
#include "AmbientOcclusionEffect.h"
#include "GlowEffect.h"
#include "ProgramObject.h"
#include "RenderUtil.h"
#include "AmbientOcclusionEffect.h"
#include "TextureCache.h"
const int ROTATION_WIDTH = 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->addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath()
_occlusionProgram->addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath()
+ "shaders/ambient_occlusion.vert");
_occlusionProgram->addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath()
_occlusionProgram->addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath()
+ "shaders/ambient_occlusion.frag");
_occlusionProgram->link();
@ -82,8 +84,8 @@ void AmbientOcclusionEffect::init() {
glBindTexture(GL_TEXTURE_2D, 0);
_blurProgram = new ProgramObject();
_blurProgram->addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + "shaders/ambient_occlusion.vert");
_blurProgram->addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/occlusion_blur.frag");
_blurProgram->addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/ambient_occlusion.vert");
_blurProgram->addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/occlusion_blur.frag");
_blurProgram->link();
_blurProgram->bind();
@ -98,25 +100,24 @@ void AmbientOcclusionEffect::render() {
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryDepthTextureID());
glBindTexture(GL_TEXTURE_2D, DependencyManager::get<TextureCache>()->getPrimaryDepthTextureID());
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, _rotationTextureID);
// render with the occlusion shader to the secondary/tertiary buffer
QOpenGLFramebufferObject* freeFBO = Application::getInstance()->getGlowEffect()->getFreeFramebufferObject();
QOpenGLFramebufferObject* freeFBO = DependencyManager::get<GlowEffect>()->getFreeFramebufferObject();
freeFBO->bind();
float left, right, bottom, top, nearVal, farVal;
glm::vec4 nearClipPlane, farClipPlane;
Application::getInstance()->computeOffAxisFrustum(
left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
_viewState->computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
int viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
const int VIEWPORT_X_INDEX = 0;
const int VIEWPORT_WIDTH_INDEX = 2;
QOpenGLFramebufferObject* primaryFBO = Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject();
QOpenGLFramebufferObject* primaryFBO = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject();
float sMin = viewport[VIEWPORT_X_INDEX] / (float)primaryFBO->width();
float sWidth = viewport[VIEWPORT_WIDTH_INDEX] / (float)primaryFBO->width();
@ -141,7 +142,7 @@ void AmbientOcclusionEffect::render() {
glActiveTexture(GL_TEXTURE0);
// now render secondary to primary with 4x4 blur
Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject()->bind();
DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind();
glEnable(GL_BLEND);
glBlendFuncSeparate(GL_ZERO, GL_SRC_COLOR, GL_ZERO, GL_ONE);

View file

@ -12,18 +12,24 @@
#ifndef hifi_AmbientOcclusionEffect_h
#define hifi_AmbientOcclusionEffect_h
#include <DependencyManager.h>
#include "ViewStateInterface.h"
class ProgramObject;
/// 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.
class AmbientOcclusionEffect {
class AmbientOcclusionEffect: public DependencyManager::Dependency {
public:
void init();
void init(ViewStateInterface* viewState);
void render();
private:
AmbientOcclusionEffect() {}
virtual ~AmbientOcclusionEffect() {}
friend class DependencyManager;
ProgramObject* _occlusionProgram;
int _nearLocation;
@ -38,6 +44,7 @@ private:
int _blurScaleLocation;
GLuint _rotationTextureID;
ViewStateInterface* _viewState;
};
#endif // hifi_AmbientOcclusionEffect_h

View file

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

View file

@ -10,17 +10,35 @@
//
// 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 "Application.h"
#include "DeferredLightingEffect.h"
#include "RenderUtil.h"
#include <GLMHelpers.h>
#include <PathUtils.h>
void DeferredLightingEffect::init() {
_simpleProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + "shaders/simple.vert");
_simpleProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/simple.frag");
#include "DeferredLightingEffect.h"
#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.bind();
@ -37,21 +55,21 @@ void DeferredLightingEffect::init() {
}
void DeferredLightingEffect::bindSimpleProgram() {
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, true, true);
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, true, true);
_simpleProgram.bind();
_simpleProgram.setUniformValue(_glowIntensityLocation, Application::getInstance()->getGlowEffect()->getIntensity());
_simpleProgram.setUniformValue(_glowIntensityLocation, DependencyManager::get<GlowEffect>()->getIntensity());
glDisable(GL_BLEND);
}
void DeferredLightingEffect::releaseSimpleProgram() {
glEnable(GL_BLEND);
_simpleProgram.release();
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, false, false);
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, false, false);
}
void DeferredLightingEffect::renderSolidSphere(float radius, int slices, int stacks) {
bindSimpleProgram();
Application::getInstance()->getGeometryCache()->renderSphere(radius, slices, stacks);
DependencyManager::get<GeometryCache>()->renderSphere(radius, slices, stacks);
releaseSimpleProgram();
}
@ -75,7 +93,7 @@ void DeferredLightingEffect::renderWireCube(float size) {
void DeferredLightingEffect::renderSolidCone(float base, float height, int slices, int stacks) {
bindSimpleProgram();
Application::getInstance()->getGeometryCache()->renderCone(base, height, slices, stacks);
DependencyManager::get<GeometryCache>()->renderCone(base, height, slices, stacks);
releaseSimpleProgram();
}
@ -117,15 +135,16 @@ void DeferredLightingEffect::addSpotLight(const glm::vec3& position, float radiu
void DeferredLightingEffect::prepare() {
// clear the normal and specular buffers
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(false, true, false);
TextureCache* textureCache = DependencyManager::get<TextureCache>();
textureCache->setPrimaryDrawBuffers(false, true, false);
glClear(GL_COLOR_BUFFER_BIT);
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(false, false, true);
textureCache->setPrimaryDrawBuffers(false, false, true);
// clearing to zero alpha for specular causes problems on my Nvidia card; clear to lowest non-zero value instead
const float MAX_SPECULAR_EXPONENT = 128.0f;
glClearColor(0.0f, 0.0f, 0.0f, 1.0f / MAX_SPECULAR_EXPONENT);
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, false, false);
textureCache->setPrimaryDrawBuffers(true, false, false);
}
void DeferredLightingEffect::render() {
@ -137,24 +156,26 @@ void DeferredLightingEffect::render() {
glDisable(GL_DEPTH_TEST);
glDisable(GL_COLOR_MATERIAL);
glDepthMask(false);
TextureCache* textureCache = DependencyManager::get<TextureCache>();
QOpenGLFramebufferObject* primaryFBO = Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject();
QOpenGLFramebufferObject* primaryFBO = textureCache->getPrimaryFramebufferObject();
primaryFBO->release();
QOpenGLFramebufferObject* freeFBO = Application::getInstance()->getGlowEffect()->getFreeFramebufferObject();
QOpenGLFramebufferObject* freeFBO = DependencyManager::get<GlowEffect>()->getFreeFramebufferObject();
freeFBO->bind();
glClear(GL_COLOR_BUFFER_BIT);
glBindTexture(GL_TEXTURE_2D, primaryFBO->texture());
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryNormalTextureID());
glBindTexture(GL_TEXTURE_2D, textureCache->getPrimaryNormalTextureID());
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimarySpecularTextureID());
glBindTexture(GL_TEXTURE_2D, textureCache->getPrimarySpecularTextureID());
glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryDepthTextureID());
glBindTexture(GL_TEXTURE_2D, textureCache->getPrimaryDepthTextureID());
// get the viewport side (left, right, both)
int viewport[4];
@ -170,25 +191,24 @@ void DeferredLightingEffect::render() {
ProgramObject* program = &_directionalLight;
const LightLocations* locations = &_directionalLightLocations;
bool shadowsEnabled = Menu::getInstance()->getShadowsEnabled();
if (shadowsEnabled) {
bool shadowsEnabled = _viewState->getShadowsEnabled();
if (shadowsEnabled) {
glActiveTexture(GL_TEXTURE4);
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getShadowDepthTextureID());
glBindTexture(GL_TEXTURE_2D, textureCache->getShadowDepthTextureID());
program = &_directionalLightShadowMap;
locations = &_directionalLightShadowMapLocations;
if (Menu::getInstance()->isOptionChecked(MenuOption::CascadedShadows)) {
if (_viewState->getCascadeShadowsEnabled()) {
program = &_directionalLightCascadedShadowMap;
locations = &_directionalLightCascadedShadowMapLocations;
_directionalLightCascadedShadowMap.bind();
_directionalLightCascadedShadowMap.setUniform(locations->shadowDistances,
Application::getInstance()->getShadowDistances());
_directionalLightCascadedShadowMap.setUniform(locations->shadowDistances, _viewState->getShadowDistances());
} else {
program->bind();
}
program->setUniformValue(locations->shadowScale,
1.0f / Application::getInstance()->getTextureCache()->getShadowFramebufferObject()->width());
1.0f / textureCache->getShadowFramebufferObject()->width());
} else {
program->bind();
@ -196,8 +216,7 @@ void DeferredLightingEffect::render() {
float left, right, bottom, top, nearVal, farVal;
glm::vec4 nearClipPlane, farClipPlane;
Application::getInstance()->computeOffAxisFrustum(
left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
_viewState->computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
program->setUniformValue(locations->nearLocation, nearVal);
float depthScale = (farVal - nearVal) / farVal;
program->setUniformValue(locations->depthScale, depthScale);
@ -232,8 +251,10 @@ void DeferredLightingEffect::render() {
// enlarge the scales slightly to account for tesselation
const float SCALE_EXPANSION = 0.05f;
const glm::vec3& eyePoint = Application::getInstance()->getDisplayViewFrustum()->getPosition();
float nearRadius = glm::distance(eyePoint, Application::getInstance()->getDisplayViewFrustum()->getNearTopLeft());
const glm::vec3& eyePoint = _viewState->getCurrentViewFrustum()->getPosition();
float nearRadius = glm::distance(eyePoint, _viewState->getCurrentViewFrustum()->getNearTopLeft());
GeometryCache* geometryCache = DependencyManager::get<GeometryCache>();
if (!_pointLights.isEmpty()) {
_pointLight.bind();
@ -241,7 +262,7 @@ void DeferredLightingEffect::render() {
_pointLight.setUniformValue(_pointLightLocations.depthScale, depthScale);
_pointLight.setUniformValue(_pointLightLocations.depthTexCoordOffset, depthTexCoordOffsetS, depthTexCoordOffsetT);
_pointLight.setUniformValue(_pointLightLocations.depthTexCoordScale, depthTexCoordScaleS, depthTexCoordScaleT);
foreach (const PointLight& light, _pointLights) {
_pointLight.setUniformValue(_pointLightLocations.radius, light.radius);
glLightfv(GL_LIGHT1, GL_AMBIENT, (const GLfloat*)&light.ambient);
@ -270,7 +291,7 @@ void DeferredLightingEffect::render() {
} else {
glTranslatef(light.position.x, light.position.y, light.position.z);
Application::getInstance()->getGeometryCache()->renderSphere(expandedRadius, 32, 32);
geometryCache->renderSphere(expandedRadius, 32, 32);
}
glPopMatrix();
@ -323,7 +344,7 @@ void DeferredLightingEffect::render() {
glm::vec3 axis = glm::axis(spotRotation);
glRotatef(glm::degrees(glm::angle(spotRotation)), axis.x, axis.y, axis.z);
glTranslatef(0.0f, 0.0f, -light.radius * (1.0f + SCALE_EXPANSION * 0.5f));
Application::getInstance()->getGeometryCache()->renderCone(expandedRadius * glm::tan(light.cutoff),
geometryCache->renderCone(expandedRadius * glm::tan(light.cutoff),
expandedRadius, 32, 1);
}
@ -389,9 +410,9 @@ void DeferredLightingEffect::render() {
}
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"));
program.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + name);
program.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + name);
program.link();
program.bind();

View file

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

View file

@ -9,19 +9,21 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
// include this before QOpenGLBuffer, which includes an earlier version of OpenGL
#include <gpu/GPUConfig.h>
#include <cmath>
#include <QNetworkReply>
#include <QRunnable>
#include <QThreadPool>
#include "Application.h"
#include "GeometryCache.h"
#include "Model.h"
#include "world.h"
#include <SharedUtil.h>
GeometryCache::GeometryCache() :
_pendingBlenders(0) {
#include "TextureCache.h"
#include "GeometryCache.h"
GeometryCache::GeometryCache() {
}
GeometryCache::~GeometryCache() {
@ -505,33 +507,6 @@ QSharedPointer<NetworkGeometry> GeometryCache::getGeometry(const QUrl& url, cons
return getResource(url, fallback, delayLoad).staticCast<NetworkGeometry>();
}
void GeometryCache::noteRequiresBlend(Model* model) {
if (_pendingBlenders < QThread::idealThreadCount()) {
if (model->maybeStartBlender()) {
_pendingBlenders++;
}
return;
}
if (!_modelsRequiringBlends.contains(model)) {
_modelsRequiringBlends.append(model);
}
}
void GeometryCache::setBlendedVertices(const QPointer<Model>& model, int blendNumber,
const QWeakPointer<NetworkGeometry>& geometry, const QVector<glm::vec3>& vertices, const QVector<glm::vec3>& normals) {
if (!model.isNull()) {
model->setBlendedVertices(blendNumber, geometry, vertices, normals);
}
_pendingBlenders--;
while (!_modelsRequiringBlends.isEmpty()) {
Model* nextModel = _modelsRequiringBlends.takeFirst();
if (nextModel && nextModel->maybeStartBlender()) {
_pendingBlenders++;
return;
}
}
}
QSharedPointer<Resource> GeometryCache::createResource(const QUrl& url,
const QSharedPointer<Resource>& fallback, bool delayLoad, const void* extra) {
QSharedPointer<NetworkGeometry> geometry(new NetworkGeometry(url, fallback.staticCast<NetworkGeometry>(), delayLoad),
@ -724,6 +699,7 @@ void NetworkGeometry::clearLoadPriority(const QPointer<QObject>& owner) {
void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& url) {
if (_meshes.size() > 0) {
TextureCache* textureCache = DependencyManager::get<TextureCache>();
for (int i = 0; i < _meshes.size(); i++) {
NetworkMesh& mesh = _meshes[i];
for (int j = 0; j < mesh.parts.size(); j++) {
@ -732,19 +708,19 @@ void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& u
QSharedPointer<NetworkTexture> matchingTexture = QSharedPointer<NetworkTexture>();
if (part.diffuseTextureName == name) {
part.diffuseTexture =
Application::getInstance()->getTextureCache()->getTexture(url, DEFAULT_TEXTURE,
textureCache->getTexture(url, DEFAULT_TEXTURE,
_geometry.meshes[i].isEye, QByteArray());
part.diffuseTexture->setLoadPriorities(_loadPriorities);
} else if (part.normalTextureName == name) {
part.normalTexture = Application::getInstance()->getTextureCache()->getTexture(url, DEFAULT_TEXTURE,
part.normalTexture = textureCache->getTexture(url, DEFAULT_TEXTURE,
false, QByteArray());
part.normalTexture->setLoadPriorities(_loadPriorities);
} else if (part.specularTextureName == name) {
part.specularTexture = Application::getInstance()->getTextureCache()->getTexture(url, DEFAULT_TEXTURE,
part.specularTexture = textureCache->getTexture(url, DEFAULT_TEXTURE,
false, QByteArray());
part.specularTexture->setLoadPriorities(_loadPriorities);
} else if (part.emissiveTextureName == name) {
part.emissiveTexture = Application::getInstance()->getTextureCache()->getTexture(url, DEFAULT_TEXTURE,
part.emissiveTexture = textureCache->getTexture(url, DEFAULT_TEXTURE,
false, QByteArray());
part.emissiveTexture->setLoadPriorities(_loadPriorities);
}
@ -937,6 +913,8 @@ void NetworkGeometry::reinsert() {
void NetworkGeometry::setGeometry(const FBXGeometry& geometry) {
_geometry = geometry;
TextureCache* textureCache = DependencyManager::get<TextureCache>();
foreach (const FBXMesh& mesh, _geometry.meshes) {
NetworkMesh networkMesh;
@ -945,28 +923,28 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) {
foreach (const FBXMeshPart& part, mesh.parts) {
NetworkMeshPart networkPart;
if (!part.diffuseTexture.filename.isEmpty()) {
networkPart.diffuseTexture = Application::getInstance()->getTextureCache()->getTexture(
networkPart.diffuseTexture = textureCache->getTexture(
_textureBase.resolved(QUrl(part.diffuseTexture.filename)), DEFAULT_TEXTURE,
mesh.isEye, part.diffuseTexture.content);
networkPart.diffuseTextureName = part.diffuseTexture.name;
networkPart.diffuseTexture->setLoadPriorities(_loadPriorities);
}
if (!part.normalTexture.filename.isEmpty()) {
networkPart.normalTexture = Application::getInstance()->getTextureCache()->getTexture(
networkPart.normalTexture = textureCache->getTexture(
_textureBase.resolved(QUrl(part.normalTexture.filename)), NORMAL_TEXTURE,
false, part.normalTexture.content);
networkPart.normalTextureName = part.normalTexture.name;
networkPart.normalTexture->setLoadPriorities(_loadPriorities);
}
if (!part.specularTexture.filename.isEmpty()) {
networkPart.specularTexture = Application::getInstance()->getTextureCache()->getTexture(
networkPart.specularTexture = textureCache->getTexture(
_textureBase.resolved(QUrl(part.specularTexture.filename)), SPECULAR_TEXTURE,
false, part.specularTexture.content);
networkPart.specularTextureName = part.specularTexture.name;
networkPart.specularTexture->setLoadPriorities(_loadPriorities);
}
if (!part.emissiveTexture.filename.isEmpty()) {
networkPart.emissiveTexture = Application::getInstance()->getTextureCache()->getTexture(
networkPart.emissiveTexture = textureCache->getTexture(
_textureBase.resolved(QUrl(part.emissiveTexture.filename)), EMISSIVE_TEXTURE,
false, part.emissiveTexture.content);
networkPart.emissiveTextureName = part.emissiveTexture.name;

View file

@ -13,11 +13,12 @@
#define hifi_GeometryCache_h
// include this before QOpenGLBuffer, which includes an earlier version of OpenGL
#include "InterfaceConfig.h"
#include <gpu/GPUConfig.h>
#include <QMap>
#include <QOpenGLBuffer>
#include <DependencyManager.h>
#include <ResourceCache.h>
#include <FBXReader.h>
@ -26,20 +27,15 @@
#include "gpu/Stream.h"
class Model;
class NetworkGeometry;
class NetworkMesh;
class NetworkTexture;
/// Stores cached geometry.
class GeometryCache : public ResourceCache {
class GeometryCache : public ResourceCache, public DependencyManager::Dependency {
Q_OBJECT
public:
GeometryCache();
virtual ~GeometryCache();
void renderHemisphere(int slices, int stacks);
void renderSphere(float radius, int slices, int stacks);
void renderSquare(int xDivisions, int yDivisions);
@ -52,20 +48,15 @@ public:
/// \param delayLoad if true, don't load the geometry immediately; wait until load is first requested
QSharedPointer<NetworkGeometry> getGeometry(const QUrl& url, const QUrl& fallback = QUrl(), bool delayLoad = false);
/// Adds the specified model to the list requiring vertex blends.
void noteRequiresBlend(Model* model);
public slots:
void setBlendedVertices(const QPointer<Model>& model, int blendNumber, const QWeakPointer<NetworkGeometry>& geometry,
const QVector<glm::vec3>& vertices, const QVector<glm::vec3>& normals);
protected:
virtual QSharedPointer<Resource> createResource(const QUrl& url,
const QSharedPointer<Resource>& fallback, bool delayLoad, const void* extra);
private:
GeometryCache();
virtual ~GeometryCache();
friend class DependencyManager;
typedef QPair<int, int> IntPair;
typedef QPair<GLuint, GLuint> VerticesIndices;
@ -78,9 +69,6 @@ private:
QHash<IntPair, QOpenGLBuffer> _gridBuffers;
QHash<QUrl, QWeakPointer<NetworkGeometry> > _networkGeometry;
QList<QPointer<Model> > _modelsRequiringBlends;
int _pendingBlenders;
};
/// Geometry loaded from the network.

View file

@ -10,22 +10,28 @@
//
// include this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL
#include "InterfaceConfig.h"
#include <gpu/GPUConfig.h>
#include <QGLWidget>
#include <QOpenGLFramebufferObject>
#include <QWindow>
#include <PathUtils.h>
#include <PerfStat.h>
#include "Application.h"
#include "GlowEffect.h"
#include "ProgramObject.h"
#include "RenderUtil.h"
#include "TextureCache.h"
GlowEffect::GlowEffect()
: _initialized(false),
_isOddFrame(false),
_isFirstFrame(true),
_intensity(0.0f) {
_intensity(0.0f),
_widget(NULL),
_enabled(false) {
}
GlowEffect::~GlowEffect() {
@ -41,13 +47,13 @@ GlowEffect::~GlowEffect() {
QOpenGLFramebufferObject* GlowEffect::getFreeFramebufferObject() const {
return (_isOddFrame ?
Application::getInstance()->getTextureCache()->getSecondaryFramebufferObject():
Application::getInstance()->getTextureCache()->getTertiaryFramebufferObject());
DependencyManager::get<TextureCache>()->getSecondaryFramebufferObject():
DependencyManager::get<TextureCache>()->getTertiaryFramebufferObject());
}
static ProgramObject* createProgram(const QString& name) {
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->bind();
@ -57,7 +63,7 @@ static ProgramObject* createProgram(const QString& name) {
return program;
}
void GlowEffect::init() {
void GlowEffect::init(QGLWidget* widget, bool enabled) {
if (_initialized) {
qDebug("[ERROR] GlowEffeect is already initialized.");
return;
@ -85,10 +91,21 @@ void GlowEffect::init() {
_diffusionScaleLocation = _diffuseProgram->uniformLocation("diffusionScale");
_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() {
Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject()->bind();
DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
_isEmpty = true;
@ -122,7 +139,8 @@ static void maybeRelease(QOpenGLFramebufferObject* fbo) {
QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
PerformanceTimer perfTimer("glowEffect");
QOpenGLFramebufferObject* primaryFBO = Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject();
TextureCache* textureCache = DependencyManager::get<TextureCache>();
QOpenGLFramebufferObject* primaryFBO = textureCache->getPrimaryFramebufferObject();
primaryFBO->release();
glBindTexture(GL_TEXTURE_2D, primaryFBO->texture());
@ -138,16 +156,15 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
glDepthMask(GL_FALSE);
QOpenGLFramebufferObject* destFBO = toTexture ?
Application::getInstance()->getTextureCache()->getSecondaryFramebufferObject() : NULL;
if (!Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect) || _isEmpty) {
textureCache->getSecondaryFramebufferObject() : NULL;
if (!_enabled || _isEmpty) {
// copy the primary to the screen
if (destFBO && QOpenGLFramebufferObject::hasOpenGLFramebufferBlit()) {
QOpenGLFramebufferObject::blitFramebuffer(destFBO, primaryFBO);
} else {
maybeBind(destFBO);
if (!destFBO) {
glViewport(0, 0, Application::getInstance()->getGLWidget()->getDeviceWidth(),
Application::getInstance()->getGLWidget()->getDeviceHeight());
glViewport(0, 0, getDeviceWidth(), getDeviceHeight());
}
glEnable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
@ -160,9 +177,9 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
} else {
// diffuse into the secondary/tertiary (alternating between frames)
QOpenGLFramebufferObject* oldDiffusedFBO =
Application::getInstance()->getTextureCache()->getSecondaryFramebufferObject();
textureCache->getSecondaryFramebufferObject();
QOpenGLFramebufferObject* newDiffusedFBO =
Application::getInstance()->getTextureCache()->getTertiaryFramebufferObject();
textureCache->getTertiaryFramebufferObject();
if (_isOddFrame) {
qSwap(oldDiffusedFBO, newDiffusedFBO);
}
@ -194,9 +211,7 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
}
maybeBind(destFBO);
if (!destFBO) {
glViewport(0, 0,
Application::getInstance()->getGLWidget()->getDeviceWidth(),
Application::getInstance()->getGLWidget()->getDeviceHeight());
glViewport(0, 0, getDeviceWidth(), getDeviceHeight());
}
_addSeparateProgram->bind();
renderFullscreenQuad();
@ -223,11 +238,15 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
return destFBO;
}
void GlowEffect::toggleGlowEffect(bool enabled) {
_enabled = enabled;
}
Glower::Glower(float amount) {
Application::getInstance()->getGlowEffect()->begin(amount);
DependencyManager::get<GlowEffect>()->begin(amount);
}
Glower::~Glower() {
Application::getInstance()->getGlowEffect()->end();
DependencyManager::get<GlowEffect>()->end();
}

View file

@ -12,26 +12,29 @@
#ifndef hifi_GlowEffect_h
#define hifi_GlowEffect_h
#include <gpu/GPUConfig.h>
#include <QObject>
#include <QGLWidget>
#include <QStack>
#include <DependencyManager.h>
class QOpenGLFramebufferObject;
class ProgramObject;
/// A generic full screen glow effect.
class GlowEffect : public QObject {
class GlowEffect : public QObject, public DependencyManager::Dependency {
Q_OBJECT
public:
GlowEffect();
~GlowEffect();
/// Returns a pointer to the framebuffer object that the glow effect is *not* using for persistent state
/// (either the secondary or the tertiary).
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.
void prepare();
@ -51,7 +54,16 @@ public:
/// \return the framebuffer object to which we rendered, or NULL if to the frame buffer
QOpenGLFramebufferObject* render(bool toTexture = false);
public slots:
void toggleGlowEffect(bool enabled);
private:
GlowEffect();
virtual ~GlowEffect();
friend class DependencyManager;
int getDeviceWidth() const;
int getDeviceHeight() const;
bool _initialized;
@ -69,6 +81,8 @@ private:
float _intensity;
QStack<float> _intensityStack;
QGLWidget* _widget;
bool _enabled;
};
/// 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
//
#include <gpu/GPUConfig.h>
#include <QMetaType>
#include <QRunnable>
#include <QThreadPool>
@ -18,17 +20,20 @@
#include <CapsuleShape.h>
#include <GeometryUtil.h>
#include <gpu/Batch.h>
#include <gpu/GLBackend.h>
#include <PathUtils.h>
#include <PerfStat.h>
#include <PhysicsEntity.h>
#include <ShapeCollider.h>
#include <SphereShape.h>
#include "AnimationHandle.h"
#include "Application.h"
#include "DeferredLightingEffect.h"
#include "GlowEffect.h"
#include "Model.h"
#include "gpu/Batch.h"
#include "gpu/GLBackend.h"
#define GLBATCH( call ) batch._##call
//#define GLBATCH( call ) call
@ -58,7 +63,9 @@ Model::Model(QObject* parent) :
_meshGroupsKnown(false) {
// 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() {
@ -104,6 +111,8 @@ Model::SkinLocations Model::_skinNormalSpecularMapLocations;
Model::SkinLocations Model::_skinShadowLocations;
Model::SkinLocations Model::_skinTranslucentLocations;
ViewStateInterface* Model::_viewState = NULL;
void Model::setScale(const glm::vec3& scale) {
setScaleInternal(scale);
// if anyone sets scale manually, then we are no longer scaled to fit
@ -222,109 +231,109 @@ void Model::initJointTransforms() {
void Model::init() {
if (!_program.isLinked()) {
_program.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + "shaders/model.vert");
_program.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/model.frag");
_program.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/model.vert");
_program.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/model.frag");
initProgram(_program, _locations);
_normalMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/model_normal_map.vert");
PathUtils::resourcesPath() + "shaders/model_normal_map.vert");
_normalMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_normal_map.frag");
PathUtils::resourcesPath() + "shaders/model_normal_map.frag");
initProgram(_normalMapProgram, _normalMapLocations);
_specularMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/model.vert");
PathUtils::resourcesPath() + "shaders/model.vert");
_specularMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_specular_map.frag");
PathUtils::resourcesPath() + "shaders/model_specular_map.frag");
initProgram(_specularMapProgram, _specularMapLocations);
_normalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/model_normal_map.vert");
PathUtils::resourcesPath() + "shaders/model_normal_map.vert");
_normalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_normal_specular_map.frag");
PathUtils::resourcesPath() + "shaders/model_normal_specular_map.frag");
initProgram(_normalSpecularMapProgram, _normalSpecularMapLocations);
_translucentProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/model.vert");
PathUtils::resourcesPath() + "shaders/model.vert");
_translucentProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_translucent.frag");
PathUtils::resourcesPath() + "shaders/model_translucent.frag");
initProgram(_translucentProgram, _translucentLocations);
// Lightmap
_lightmapProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + "shaders/model_lightmap.vert");
_lightmapProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/model_lightmap.frag");
_lightmapProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/model_lightmap.vert");
_lightmapProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/model_lightmap.frag");
initProgram(_lightmapProgram, _lightmapLocations);
_lightmapNormalMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/model_lightmap_normal_map.vert");
PathUtils::resourcesPath() + "shaders/model_lightmap_normal_map.vert");
_lightmapNormalMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_lightmap_normal_map.frag");
PathUtils::resourcesPath() + "shaders/model_lightmap_normal_map.frag");
initProgram(_lightmapNormalMapProgram, _lightmapNormalMapLocations);
_lightmapSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/model_lightmap.vert");
PathUtils::resourcesPath() + "shaders/model_lightmap.vert");
_lightmapSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_lightmap_specular_map.frag");
PathUtils::resourcesPath() + "shaders/model_lightmap_specular_map.frag");
initProgram(_lightmapSpecularMapProgram, _lightmapSpecularMapLocations);
_lightmapNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/model_lightmap_normal_map.vert");
PathUtils::resourcesPath() + "shaders/model_lightmap_normal_map.vert");
_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);
// 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,
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::Fragment, Application::resourcesPath() + "shaders/model.frag");
_skinProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/skin_model.vert");
_skinProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/model.frag");
initSkinProgram(_skinProgram, _skinLocations);
_skinNormalMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/skin_model_normal_map.vert");
PathUtils::resourcesPath() + "shaders/skin_model_normal_map.vert");
_skinNormalMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_normal_map.frag");
PathUtils::resourcesPath() + "shaders/model_normal_map.frag");
initSkinProgram(_skinNormalMapProgram, _skinNormalMapLocations);
_skinSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/skin_model.vert");
PathUtils::resourcesPath() + "shaders/skin_model.vert");
_skinSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_specular_map.frag");
PathUtils::resourcesPath() + "shaders/model_specular_map.frag");
initSkinProgram(_skinSpecularMapProgram, _skinSpecularMapLocations);
_skinNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/skin_model_normal_map.vert");
PathUtils::resourcesPath() + "shaders/skin_model_normal_map.vert");
_skinNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_normal_specular_map.frag");
PathUtils::resourcesPath() + "shaders/model_normal_specular_map.frag");
initSkinProgram(_skinNormalSpecularMapProgram, _skinNormalSpecularMapLocations);
_skinShadowProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/skin_model_shadow.vert");
PathUtils::resourcesPath() + "shaders/skin_model_shadow.vert");
_skinShadowProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_shadow.frag");
PathUtils::resourcesPath() + "shaders/model_shadow.frag");
initSkinProgram(_skinShadowProgram, _skinShadowLocations);
_skinTranslucentProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/skin_model.vert");
PathUtils::resourcesPath() + "shaders/skin_model.vert");
_skinTranslucentProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/model_translucent.frag");
PathUtils::resourcesPath() + "shaders/model_translucent.frag");
initSkinProgram(_skinTranslucentProgram, _skinTranslucentLocations);
}
@ -491,7 +500,7 @@ bool Model::renderTriangleProxies() {
glPushMatrix();
glTranslatef(center.x, center.y, center.z);
glScalef(dimensions.x, dimensions.y, dimensions.z);
Application::getInstance()->getDeferredLightingEffect()->renderWireCube(1.0f);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f);
glPopMatrix();
}
@ -712,6 +721,9 @@ bool Model::render(float alpha, RenderMode mode, RenderArgs* args) {
bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) {
PROFILE_RANGE(__FUNCTION__);
if (!_viewState) {
return false;
}
// Let's introduce a gpu::Batch to capture all the calls to the graphics api
_renderBatch.clear();
@ -722,7 +734,7 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) {
if (_transforms.empty()) {
_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)
_transforms[0].preTranslate(-_translation);
@ -749,7 +761,7 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) {
}
/*Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(
/*DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(
mode == DEFAULT_RENDER_MODE || mode == DIFFUSE_RENDER_MODE,
mode == DEFAULT_RENDER_MODE || mode == NORMAL_RENDER_MODE,
mode == DEFAULT_RENDER_MODE);
@ -789,7 +801,7 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) {
opaqueMeshPartsRendered += renderMeshes(batch, mode, false, DEFAULT_ALPHA_THRESHOLD, true, true, true, false, args);
// render translucent meshes afterwards
//Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(false, true, true);
//DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(false, true, true);
{
GLenum buffers[2];
int bufferCount = 0;
@ -814,7 +826,7 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) {
GLBATCH(glDepthMask)(false);
GLBATCH(glDepthFunc)(GL_LEQUAL);
//Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true);
//DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true);
{
GLenum buffers[1];
int bufferCount = 0;
@ -865,7 +877,7 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) {
}
// restore all the default material settings
Application::getInstance()->setupWorldLight();
_viewState->setupWorldLight();
if (args) {
args->_translucentMeshPartsRendered = translucentMeshPartsRendered;
@ -997,7 +1009,7 @@ void Model::setURL(const QUrl& url, const QUrl& fallback, bool retainCurrent, bo
_url = url;
// if so instructed, keep the current geometry until the new one is loaded
_nextBaseGeometry = _nextGeometry = Application::getInstance()->getGeometryCache()->getGeometry(url, fallback, delayLoad);
_nextBaseGeometry = _nextGeometry = DependencyManager::get<GeometryCache>()->getGeometry(url, fallback, delayLoad);
_nextLODHysteresis = NetworkGeometry::NO_HYSTERESIS;
if (!retainCurrent || !isActive() || _nextGeometry->isLoaded()) {
applyNextGeometry();
@ -1149,7 +1161,7 @@ void Blender::run() {
}
}
// post the result to the geometry cache, which will dispatch to the model if still alive
QMetaObject::invokeMethod(Application::getInstance()->getGeometryCache(), "setBlendedVertices",
QMetaObject::invokeMethod(DependencyManager::get<ModelBlender>(), "setBlendedVertices",
Q_ARG(const QPointer<Model>&, _model), Q_ARG(int, _blendNumber),
Q_ARG(const QWeakPointer<NetworkGeometry>&, _geometry), Q_ARG(const QVector<glm::vec3>&, vertices),
Q_ARG(const QVector<glm::vec3>&, normals));
@ -1312,7 +1324,7 @@ void Model::simulateInternal(float deltaTime) {
// post the blender if we're not currently waiting for one to finish
if (geometry.hasBlendedMeshes() && _blendshapeCoefficients != _blendedBlendshapeCoefficients) {
_blendedBlendshapeCoefficients = _blendshapeCoefficients;
Application::getInstance()->getGeometryCache()->noteRequiresBlend(this);
DependencyManager::get<ModelBlender>()->noteRequiresBlend(this);
}
}
@ -1665,7 +1677,7 @@ void Model::setupBatchTransform(gpu::Batch& batch) {
if (_transforms.empty()) {
_transforms.push_back(Transform());
}
_transforms[0] = Application::getInstance()->getViewTransform();
_transforms[0] = _viewState->getViewTransform();
_transforms[0].preTranslate(-_translation);
batch.setViewTransform(_transforms[0]);
}
@ -1705,7 +1717,7 @@ void Model::endScene(RenderMode mode, RenderArgs* args) {
}
/*Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(
/*DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(
mode == DEFAULT_RENDER_MODE || mode == DIFFUSE_RENDER_MODE,
mode == DEFAULT_RENDER_MODE || mode == NORMAL_RENDER_MODE,
mode == DEFAULT_RENDER_MODE);
@ -1745,7 +1757,7 @@ void Model::endScene(RenderMode mode, RenderArgs* args) {
opaqueMeshPartsRendered += renderMeshesForModelsInScene(batch, mode, false, DEFAULT_ALPHA_THRESHOLD, true, true, true, false, args);
// render translucent meshes afterwards
//Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(false, true, true);
//DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(false, true, true);
{
GLenum buffers[2];
int bufferCount = 0;
@ -1770,7 +1782,7 @@ void Model::endScene(RenderMode mode, RenderArgs* args) {
GLBATCH(glDepthMask)(false);
GLBATCH(glDepthFunc)(GL_LEQUAL);
//Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true);
//DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true);
{
GLenum buffers[1];
int bufferCount = 0;
@ -1825,7 +1837,7 @@ void Model::endScene(RenderMode mode, RenderArgs* args) {
}
// restore all the default material settings
Application::getInstance()->setupWorldLight();
_viewState->setupWorldLight();
}
@ -2321,10 +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,
Locations* locations, SkinLocations* skinLocations) {
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>();
GlowEffect* glowEffect = DependencyManager::get<GlowEffect>();
QString lastMaterialID;
int meshPartsRendered = 0;
updateVisibleJointStates();
@ -2359,11 +2370,10 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
args->_meshesConsidered++;
if (args->_viewFrustum) {
shouldRender = dontCullOutOfViewMeshParts ||
args->_viewFrustum->boxInFrustum(_calculatedMeshBoxes.at(i)) != ViewFrustum::OUTSIDE;
if (shouldRender && cullTooSmallMeshParts) {
shouldRender = args->_viewFrustum->boxInFrustum(_calculatedMeshBoxes.at(i)) != ViewFrustum::OUTSIDE;
if (shouldRender) {
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);
if (!shouldRender) {
args->_meshesTooSmall++;
@ -2419,7 +2429,7 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
GLBATCH(glBindTexture)(GL_TEXTURE_2D, 0);
} else {
if (dontReduceMaterialSwitches || lastMaterialID != part.materialID) {
if (lastMaterialID != part.materialID) {
const bool wantDebug = false;
if (wantDebug) {
qDebug() << "Material Changed ---------------------------------------------";
@ -2429,7 +2439,7 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
glm::vec4 diffuse = glm::vec4(part.diffuseColor, part.opacity);
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);
GLBATCH(glMaterialfv)(GL_FRONT, GL_AMBIENT, (const float*)&diffuse);
@ -2446,7 +2456,7 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
if (showDiffuse && diffuseMap) {
GLBATCH(glBindTexture)(GL_TEXTURE_2D, diffuseMap->getID());
} else {
GLBATCH(glBindTexture)(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getWhiteTextureID());
GLBATCH(glBindTexture)(GL_TEXTURE_2D, textureCache->getWhiteTextureID());
}
if (locations->texcoordMatrices >= 0) {
@ -2464,7 +2474,7 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
GLBATCH(glActiveTexture)(GL_TEXTURE1);
Texture* normalMap = networkPart.normalTexture.data();
GLBATCH(glBindTexture)(GL_TEXTURE_2D, !normalMap ?
Application::getInstance()->getTextureCache()->getBlueTextureID() : normalMap->getID());
textureCache->getBlueTextureID() : normalMap->getID());
GLBATCH(glActiveTexture)(GL_TEXTURE0);
}
@ -2472,7 +2482,7 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
GLBATCH(glActiveTexture)(GL_TEXTURE0 + locations->specularTextureUnit);
Texture* specularMap = networkPart.specularTexture.data();
GLBATCH(glBindTexture)(GL_TEXTURE_2D, !specularMap ?
Application::getInstance()->getTextureCache()->getWhiteTextureID() : specularMap->getID());
textureCache->getWhiteTextureID() : specularMap->getID());
GLBATCH(glActiveTexture)(GL_TEXTURE0);
}
@ -2493,7 +2503,7 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
GLBATCH(glActiveTexture)(GL_TEXTURE0 + locations->emissiveTextureUnit);
Texture* emissiveMap = networkPart.emissiveTexture.data();
GLBATCH(glBindTexture)(GL_TEXTURE_2D, !emissiveMap ?
Application::getInstance()->getTextureCache()->getWhiteTextureID() : emissiveMap->getID());
textureCache->getWhiteTextureID() : emissiveMap->getID());
GLBATCH(glActiveTexture)(GL_TEXTURE0);
}
@ -2544,3 +2554,38 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
return meshPartsRendered;
}
ModelBlender::ModelBlender() :
_pendingBlenders(0) {
}
ModelBlender::~ModelBlender() {
}
void ModelBlender::noteRequiresBlend(Model* model) {
if (_pendingBlenders < QThread::idealThreadCount()) {
if (model->maybeStartBlender()) {
_pendingBlenders++;
}
return;
}
if (!_modelsRequiringBlends.contains(model)) {
_modelsRequiringBlends.append(model);
}
}
void ModelBlender::setBlendedVertices(const QPointer<Model>& model, int blendNumber,
const QWeakPointer<NetworkGeometry>& geometry, const QVector<glm::vec3>& vertices, const QVector<glm::vec3>& normals) {
if (!model.isNull()) {
model->setBlendedVertices(blendNumber, geometry, vertices, normals);
}
_pendingBlenders--;
while (!_modelsRequiringBlends.isEmpty()) {
Model* nextModel = _modelsRequiringBlends.takeFirst();
if (nextModel && nextModel->maybeStartBlender()) {
_pendingBlenders++;
return;
}
}
}

View file

@ -12,22 +12,27 @@
#ifndef hifi_Model_h
#define hifi_Model_h
#include <gpu/GPUConfig.h>
#include <QBitArray>
#include <QObject>
#include <QUrl>
#include "Transform.h"
#include <AABox.h>
#include <AnimationCache.h>
#include <DependencyManager.h>
#include <GeometryUtil.h>
#include <gpu/Stream.h>
#include <gpu/Batch.h>
#include <PhysicsEntity.h>
#include <Transform.h>
#include "AnimationHandle.h"
#include "GeometryCache.h"
#include "InterfaceConfig.h"
#include "JointState.h"
#include "ProgramObject.h"
#include "TextureCache.h"
#include "ViewStateInterface.h"
class QScriptEngine;
@ -35,8 +40,6 @@ class Shape;
#include "RenderArgs.h"
class ViewFrustum;
#include "gpu/Stream.h"
#include "gpu/Batch.h"
/// A generic 3D model displaying geometry loaded from a URL.
class Model : public QObject, public PhysicsEntity {
@ -44,6 +47,8 @@ class Model : public QObject, public PhysicsEntity {
public:
static void setViewStateInterface(ViewStateInterface* viewState) { _viewState = viewState; }
Model(QObject* parent = NULL);
virtual ~Model();
@ -454,11 +459,35 @@ private:
bool hasLightmap, bool hasTangents, bool hasSpecular, bool isSkinned, RenderArgs* args);
static ViewStateInterface* _viewState;
};
Q_DECLARE_METATYPE(QPointer<Model>)
Q_DECLARE_METATYPE(QWeakPointer<NetworkGeometry>)
Q_DECLARE_METATYPE(QVector<glm::vec3>)
/// Handle management of pending models that need blending
class ModelBlender : public QObject, public DependencyManager::Dependency {
Q_OBJECT
public:
/// Adds the specified model to the list requiring vertex blends.
void noteRequiresBlend(Model* model);
public slots:
void setBlendedVertices(const QPointer<Model>& model, int blendNumber, const QWeakPointer<NetworkGeometry>& geometry,
const QVector<glm::vec3>& vertices, const QVector<glm::vec3>& normals);
private:
ModelBlender();
virtual ~ModelBlender();
friend class DependencyManager;
QList<QPointer<Model> > _modelsRequiringBlends;
int _pendingBlenders;
};
#endif // hifi_Model_h

View file

@ -9,9 +9,10 @@
// 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 "ProgramObject.h"
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
//
#include "InterfaceConfig.h"
#include <gpu/GPUConfig.h>
#include "RenderUtil.h"
void renderFullscreenQuad(float sMin, float sMax, float tMin, float tMax) {

View file

@ -10,18 +10,19 @@
//
// include this before QGLWidget, which includes an earlier version of OpenGL
#include "InterfaceConfig.h"
#include <gpu/GPUConfig.h>
#include <QEvent>
#include <QGLWidget>
#include <QNetworkReply>
#include <QOpenGLFramebufferObject>
#include <QResizeEvent>
#include <QRunnable>
#include <QThreadPool>
#include <glm/glm.hpp>
#include <glm/gtc/random.hpp>
#include "Application.h"
#include "TextureCache.h"
TextureCache::TextureCache() :
@ -35,7 +36,8 @@ TextureCache::TextureCache() :
_secondaryFramebufferObject(NULL),
_tertiaryFramebufferObject(NULL),
_shadowFramebufferObject(NULL),
_frameBufferSize(100, 100)
_frameBufferSize(100, 100),
_associatedWidget(NULL)
{
}
@ -350,9 +352,16 @@ QSharedPointer<Resource> TextureCache::createResource(const QUrl& url,
&Resource::allReferencesCleared);
}
void TextureCache::associateWithWidget(QGLWidget* widget) {
if (_associatedWidget) {
_associatedWidget->removeEventFilter(this);
}
_associatedWidget = widget;
_associatedWidget->installEventFilter(this);
}
QOpenGLFramebufferObject* TextureCache::createFramebufferObject() {
QOpenGLFramebufferObject* fbo = new QOpenGLFramebufferObject(_frameBufferSize);
Application::getInstance()->getGLWidget()->installEventFilter(this);
glBindTexture(GL_TEXTURE_2D, fbo->texture());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

View file

@ -12,13 +12,15 @@
#ifndef hifi_TextureCache_h
#define hifi_TextureCache_h
#include <gpu/GPUConfig.h>
#include <QImage>
#include <QMap>
#include <QGLWidget>
#include <DependencyManager.h>
#include <ResourceCache.h>
#include "InterfaceConfig.h"
class QOpenGLFramebufferObject;
class NetworkTexture;
@ -28,13 +30,12 @@ typedef QSharedPointer<NetworkTexture> NetworkTexturePointer;
enum TextureType { DEFAULT_TEXTURE, NORMAL_TEXTURE, SPECULAR_TEXTURE, EMISSIVE_TEXTURE, SPLAT_TEXTURE };
/// Stores cached textures, including render-to-texture targets.
class TextureCache : public ResourceCache {
class TextureCache : public ResourceCache, public DependencyManager::Dependency {
Q_OBJECT
public:
TextureCache();
virtual ~TextureCache();
void associateWithWidget(QGLWidget* widget);
/// Sets the desired texture resolution for the framebuffer objects.
void setFrameBufferSize(QSize frameBufferSize);
@ -93,7 +94,9 @@ protected:
const QSharedPointer<Resource>& fallback, bool delayLoad, const void* extra);
private:
TextureCache();
virtual ~TextureCache();
friend class DependencyManager;
friend class DilatableNetworkTexture;
QOpenGLFramebufferObject* createFramebufferObject();
@ -115,6 +118,7 @@ private:
GLuint _shadowDepthTextureID;
QSize _frameBufferSize;
QGLWidget* _associatedWidget;
};
/// A simple object wrapper for an OpenGL texture.

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(),
_vec3Library(),
_uuidLibrary(),
_animationCache(this),
_isUserLoaded(false),
_arrayBufferClass(new ArrayBufferClass(this))
{
@ -256,7 +255,7 @@ void ScriptEngine::init() {
registerGlobalObject("Quat", &_quatLibrary);
registerGlobalObject("Vec3", &_vec3Library);
registerGlobalObject("Uuid", &_uuidLibrary);
registerGlobalObject("AnimationCache", &_animationCache);
registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>());
registerGlobalObject("Voxels", &_voxelsScriptingInterface);

View file

@ -51,7 +51,6 @@ public:
static EntityScriptingInterface* getEntityScriptingInterface() { return &_entityScriptingInterface; }
ArrayBufferClass* getArrayBufferClass() { return _arrayBufferClass; }
AnimationCache* getAnimationCache() { return &_animationCache; }
/// 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(""));
@ -149,7 +148,6 @@ private:
Quat _quatLibrary;
Vec3 _vec3Library;
ScriptUUID _uuidLibrary;
AnimationCache _animationCache;
bool _isUserLoaded;
ArrayBufferClass* _arrayBufferClass;

Some files were not shown because too many files have changed in this diff Show more