From 403f91c988034d50c4975b9b48549a33043d0d74 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 6 Mar 2014 10:41:11 -0800 Subject: [PATCH] update resource references to use Qt resource system --- interface/resources/images/close.svg | 16 -- .../resources/images/hifi-interface-tools.svg | 177 ------------------ interface/resources/interface.qrc | 3 - interface/resources/shaders/voxel.geom | 77 -------- interface/resources/styles/import_dialog.qss | 6 +- interface/resources/styles/log_dialog.qss | 8 +- interface/src/Application.cpp | 14 +- interface/src/Audio.cpp | 5 +- interface/src/Environment.cpp | 3 +- interface/src/ImportDialog.cpp | 24 +-- interface/src/InfoView.cpp | 7 +- interface/src/MetavoxelSystem.cpp | 3 +- interface/src/PieMenu.cpp | 1 - interface/src/VoxelSystem.cpp | 7 +- interface/src/avatar/Avatar.cpp | 4 +- interface/src/devices/OculusManager.cpp | 3 +- interface/src/devices/Visage.cpp | 5 +- .../src/renderer/AmbientOcclusionEffect.cpp | 9 +- interface/src/renderer/GlowEffect.cpp | 4 +- interface/src/renderer/Model.cpp | 17 +- interface/src/renderer/PointShader.cpp | 3 +- interface/src/renderer/TextureCache.cpp | 1 - interface/src/renderer/VoxelShader.cpp | 6 +- interface/src/ui/LogDialog.cpp | 3 +- interface/src/ui/MetavoxelEditor.cpp | 4 +- interface/src/ui/RearMirrorTools.cpp | 11 +- libraries/shared/src/SharedUtil.cpp | 15 -- libraries/shared/src/SharedUtil.h | 2 - 28 files changed, 60 insertions(+), 378 deletions(-) delete mode 100644 interface/resources/images/close.svg delete mode 100644 interface/resources/images/hifi-interface-tools.svg delete mode 100644 interface/resources/shaders/voxel.geom diff --git a/interface/resources/images/close.svg b/interface/resources/images/close.svg deleted file mode 100644 index 9c573564e6..0000000000 --- a/interface/resources/images/close.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - close - Created with Sketch (http://www.bohemiancoding.com/sketch) - - - - - - - - - - - - \ No newline at end of file diff --git a/interface/resources/images/hifi-interface-tools.svg b/interface/resources/images/hifi-interface-tools.svg deleted file mode 100644 index 311514581f..0000000000 --- a/interface/resources/images/hifi-interface-tools.svg +++ /dev/null @@ -1,177 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/interface/resources/interface.qrc b/interface/resources/interface.qrc index c0e214509d..5834bceff7 100644 --- a/interface/resources/interface.qrc +++ b/interface/resources/interface.qrc @@ -15,10 +15,8 @@ icons/voxel.svg images/body.png images/close.png - images/close.svg images/head.png images/hifi-interface-tools-v2-pie.svg - images/hifi-interface-tools.svg images/mic.svg images/mute.svg images/reset.png @@ -57,7 +55,6 @@ shaders/SkyFromSpace.vert shaders/vertical_blur_add.frag shaders/vertical_blur.frag - shaders/voxels.geom sounds/snap.wav styles/checked.svg styles/import_dialog.qss diff --git a/interface/resources/shaders/voxel.geom b/interface/resources/shaders/voxel.geom deleted file mode 100644 index ca8f729542..0000000000 --- a/interface/resources/shaders/voxel.geom +++ /dev/null @@ -1,77 +0,0 @@ -#version 120 -#extension GL_ARB_geometry_shader4 : enable - -// -// VOXEL GEOMETRY SHADER -// -// Input: gl_VerticesIn/gl_PositionIn -// GL_POINTS -// Assumes vertex shader has not transformed coordinates -// Each gl_PositionIn is the corner of voxel -// varying voxelSize - which is the voxel size -// -// Note: In vertex shader doesn't do any transform. Therefore passing the 3D world coordinates xyz to us -// -// Output: GL_TRIANGLE_STRIP -// -// Issues: -// how do we need to handle lighting of these colors?? -// how do we handle normals? -// check for size=0 and don't output the primitive -// - -varying in float voxelSize[1]; - -const int VERTICES_PER_FACE = 4; -const int COORD_PER_VERTEX = 3; -const int COORD_PER_FACE = COORD_PER_VERTEX * VERTICES_PER_FACE; - -void faceOfVoxel(vec4 corner, float scale, float[COORD_PER_FACE] facePoints, vec4 color, vec4 normal) { - for (int v = 0; v < VERTICES_PER_FACE; v++ ) { - vec4 vertex = corner; - for (int c = 0; c < COORD_PER_VERTEX; c++ ) { - int cIndex = c + (v * COORD_PER_VERTEX); - vertex[c] += (facePoints[cIndex] * scale); - } - - gl_FrontColor = color * (gl_LightModel.ambient + gl_LightSource[0].ambient + - gl_LightSource[0].diffuse * max(0.0, dot(normal, gl_LightSource[0].position))); - - gl_Position = gl_ModelViewProjectionMatrix * vertex; - EmitVertex(); - } - EndPrimitive(); -} - - -void main() { - //increment variable - int i; - vec4 corner; - float scale; - - float bottomFace[COORD_PER_FACE] = float[COORD_PER_FACE]( 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1 ); - float topFace[COORD_PER_FACE] = float[COORD_PER_FACE]( 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1 ); - float rightFace[COORD_PER_FACE] = float[COORD_PER_FACE]( 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1 ); - float leftFace[COORD_PER_FACE] = float[COORD_PER_FACE]( 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1 ); - float frontFace[COORD_PER_FACE] = float[COORD_PER_FACE]( 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0 ); - float backFace[COORD_PER_FACE] = float[COORD_PER_FACE]( 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1 ); - - vec4 bottomNormal = vec4(0.0, -1, 0.0, 0.0); - vec4 topNormal = vec4(0.0, 1, 0.0, 0.0); - vec4 rightNormal = vec4( -1, 0.0, 0.0, 0.0); - vec4 leftNormal = vec4( 1, 0.0, 0.0, 0.0); - vec4 frontNormal = vec4(0.0, 0.0, -1, 0.0); - vec4 backNormal = vec4(0.0, 0.0, 1, 0.0); - - for(i = 0; i < gl_VerticesIn; i++) { - corner = gl_PositionIn[i]; - scale = voxelSize[i]; - faceOfVoxel(corner, scale, bottomFace, gl_FrontColorIn[i], bottomNormal); - faceOfVoxel(corner, scale, topFace, gl_FrontColorIn[i], topNormal ); - faceOfVoxel(corner, scale, rightFace, gl_FrontColorIn[i], rightNormal ); - faceOfVoxel(corner, scale, leftFace, gl_FrontColorIn[i], leftNormal ); - faceOfVoxel(corner, scale, frontFace, gl_FrontColorIn[i], frontNormal ); - faceOfVoxel(corner, scale, backFace, gl_FrontColorIn[i], backNormal ); - } -} \ No newline at end of file diff --git a/interface/resources/styles/import_dialog.qss b/interface/resources/styles/import_dialog.qss index bb83ce70ed..eaf87b5d4e 100644 --- a/interface/resources/styles/import_dialog.qss +++ b/interface/resources/styles/import_dialog.qss @@ -63,17 +63,17 @@ QPushButton#cancelButton { } #backButton { - background-image: url(resources/icons/backButton.svg); + background-image: url(qrc://icons/backButton.svg); border-radius: 0px; } #forwardButton { - background-image: url(resources/icons/forwardButton.svg); + background-image: url(qrc://icons/forwardButton.svg); border-radius: 0px; } #toParentButton { - background-image: url(resources/icons/toParentButton.svg); + background-image: url(qrc://icons/toParentButton.svg); border-radius: 0px; } diff --git a/interface/resources/styles/log_dialog.qss b/interface/resources/styles/log_dialog.qss index 00f90ca5ed..d3ed5d44fb 100644 --- a/interface/resources/styles/log_dialog.qss +++ b/interface/resources/styles/log_dialog.qss @@ -21,7 +21,7 @@ QLineEdit { } QPushButton#searchButton { - background: url(resources/styles/search.svg); + background: url(qrc://styles/search.svg); background-repeat: none; background-position: left center; background-origin: content; @@ -33,7 +33,7 @@ QPushButton#searchButton { } QPushButton#revealLogButton { - background: url(resources/styles/txt-file.svg); + background: url(qrc://styles/txt-file.svg); background-repeat: none; background-position: left center; background-origin: content; @@ -50,9 +50,9 @@ QCheckBox { } QCheckBox::indicator:unchecked { - image: url(resources/styles/unchecked.svg); + image: url(qrc://styles/unchecked.svg); } QCheckBox::indicator:checked { - image: url(resources/styles/checked.svg); + image: url(qrc://styles/checked.svg); } diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6f3e745f21..d610564565 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -153,10 +153,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : _resetRecentMaxPacketsSoon(true), _logger(new FileLogger(this)) { - switchToResourcesParentIfRequired(); - // read the ApplicationInfo.ini file for Name/Version/Domain information - QSettings applicationInfo("resources/info/ApplicationInfo.ini", QSettings::IniFormat); + QSettings applicationInfo(":/info/ApplicationInfo.ini", QSettings::IniFormat); // set the associated application properties applicationInfo.beginGroup("INFO"); @@ -174,7 +172,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : _applicationStartupTime = startup_time; - QFontDatabase::addApplicationFont("resources/styles/Inconsolata.otf"); + QFontDatabase::addApplicationFont(":/styles/Inconsolata.otf"); _window->setWindowTitle("Interface"); qInstallMessageHandler(messageHandler); @@ -284,9 +282,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : restoreSizeAndPosition(); - QFontDatabase fontDatabase; - fontDatabase.addApplicationFont("resources/styles/Inconsolata.otf"); - _window->setVisible(true); _glWidget->setFocusPolicy(Qt::StrongFocus); _glWidget->setFocus(); @@ -1571,7 +1566,7 @@ void Application::init() { ScriptEngine::getParticlesScriptingInterface(), SLOT(forwardParticleCollisionWithParticle(const ParticleID&, const ParticleID&, const glm::vec3&))); - _pieMenu.init("./resources/images/hifi-interface-tools-v2-pie.svg", + _pieMenu.init(":/images/hifi-interface-tools-v2-pie.svg", _glWidget->width(), _glWidget->height()); @@ -3652,9 +3647,8 @@ void Application::skipVersion(QString latestVersion) { } void Application::takeSnapshot() { - switchToResourcesParentIfRequired(); QMediaPlayer* player = new QMediaPlayer(); - QFileInfo inf = QFileInfo("resources/sounds/snap.wav"); + QFileInfo inf = QFileInfo(":/sounds/snap.wav"); player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); player->play(); diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 66c8dbd5d0..ef2f62509c 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -88,9 +88,8 @@ Audio::Audio(Oscilloscope* scope, int16_t initialJitterBufferSamples, QObject* p } void Audio::init(QGLWidget *parent) { - switchToResourcesParentIfRequired(); - _micTextureId = parent->bindTexture(QImage("./resources/images/mic.svg")); - _muteTextureId = parent->bindTexture(QImage("./resources/images/mute.svg")); + _micTextureId = parent->bindTexture(QImage(":/images/mic.svg")); + _muteTextureId = parent->bindTexture(QImage(":/images/mute.svg")); } void Audio::reset() { diff --git a/interface/src/Environment.cpp b/interface/src/Environment.cpp index 59f16fc5eb..40c6510231 100644 --- a/interface/src/Environment.cpp +++ b/interface/src/Environment.cpp @@ -44,7 +44,6 @@ void Environment::init() { return; } - switchToResourcesParentIfRequired(); _skyFromAtmosphereProgram = createSkyProgram("Atmosphere", _skyFromAtmosphereUniformLocations); _skyFromSpaceProgram = createSkyProgram("Space", _skyFromSpaceUniformLocations); @@ -174,7 +173,7 @@ int Environment::parseData(const HifiSockAddr& senderAddress, const QByteArray& ProgramObject* Environment::createSkyProgram(const char* from, int* locations) { ProgramObject* program = new ProgramObject(); - QByteArray prefix = QByteArray("resources/shaders/SkyFrom") + from; + QByteArray prefix = QByteArray(":/shaders/SkyFrom") + from; program->addShaderFromSourceFile(QGLShader::Vertex, prefix + ".vert"); program->addShaderFromSourceFile(QGLShader::Fragment, prefix + ".frag"); program->link(); diff --git a/interface/src/ImportDialog.cpp b/interface/src/ImportDialog.cpp index 59c8c93f26..9468148831 100644 --- a/interface/src/ImportDialog.cpp +++ b/interface/src/ImportDialog.cpp @@ -27,8 +27,6 @@ const int SECOND_INDEX_LETTER = 1; QIcon HiFiIconProvider::icon(QFileIconProvider::IconType type) const { - switchToResourcesParentIfRequired(); - // types // Computer, Desktop, Trashcan, Network, Drive, Folder, File QString typeString; @@ -54,30 +52,29 @@ QIcon HiFiIconProvider::icon(QFileIconProvider::IconType type) const { break; } - return QIcon("resources/icons/" + typeString + ".svg"); + return QIcon(":/icons/" + typeString + ".svg"); } QIcon HiFiIconProvider::icon(const QFileInfo &info) const { - switchToResourcesParentIfRequired(); const QString ext = info.suffix().toLower(); if (info.isDir()) { if (info.absoluteFilePath() == QDir::homePath()) { - return QIcon("resources/icons/home.svg"); + return QIcon(":/icons/home.svg"); } else if (info.absoluteFilePath() == QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)) { - return QIcon("resources/icons/desktop.svg"); + return QIcon(":/icons/desktop.svg"); } else if (info.absoluteFilePath() == QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)) { - return QIcon("resources/icons/documents.svg"); + return QIcon(":/icons/documents.svg"); } - return QIcon("resources/icons/folder.svg"); + return QIcon(":/icons/folder.svg"); } - QFileInfo iconFile("resources/icons/" + iconsMap[ext]); + QFileInfo iconFile(":/icons/" + iconsMap[ext]); if (iconFile.exists() && iconFile.isFile()) { return QIcon(iconFile.filePath()); } - return QIcon("resources/icons/file.svg"); + return QIcon(":/icons/file.svg"); } QString HiFiIconProvider::type(const QFileInfo &info) const { @@ -245,8 +242,7 @@ void ImportDialog::setLayout() { widget = findChild("treeView"); widget->setAttribute(Qt::WA_MacShowFocusRect, false); - switchToResourcesParentIfRequired(); - QFile styleSheet("resources/styles/import_dialog.qss"); + QFile styleSheet(":/styles/import_dialog.qss"); if (styleSheet.open(QIODevice::ReadOnly)) { setStyleSheet(styleSheet.readAll()); } @@ -254,9 +250,7 @@ void ImportDialog::setLayout() { } void ImportDialog::setImportTypes() { - - switchToResourcesParentIfRequired(); - QFile config("resources/config/config.json"); + QFile config(":/config/config.json"); config.open(QFile::ReadOnly | QFile::Text); QJsonDocument document = QJsonDocument::fromJson(config.readAll()); if (!document.isNull() && !document.isEmpty()) { diff --git a/interface/src/InfoView.cpp b/interface/src/InfoView.cpp index 8de171deef..9336d4f957 100644 --- a/interface/src/InfoView.cpp +++ b/interface/src/InfoView.cpp @@ -18,12 +18,11 @@ #define MAX_DIALOG_HEIGHT_RATIO 0.9 InfoView::InfoView(bool forced) : - _forced(forced) { - + _forced(forced) +{ setWindowFlags(Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint); - switchToResourcesParentIfRequired(); - QString absPath = QFileInfo("resources/html/interface-welcome-allsvg.html").absoluteFilePath(); + QString absPath = QFileInfo(":/html/interface-welcome-allsvg.html").absoluteFilePath(); QUrl url = QUrl::fromLocalFile(absPath); load(url); diff --git a/interface/src/MetavoxelSystem.cpp b/interface/src/MetavoxelSystem.cpp index eeb92be5ec..fa393a8cfe 100644 --- a/interface/src/MetavoxelSystem.cpp +++ b/interface/src/MetavoxelSystem.cpp @@ -30,8 +30,7 @@ MetavoxelSystem::MetavoxelSystem() : void MetavoxelSystem::init() { if (!_program.isLinked()) { - switchToResourcesParentIfRequired(); - _program.addShaderFromSourceFile(QGLShader::Vertex, "resources/shaders/metavoxel_point.vert"); + _program.addShaderFromSourceFile(QGLShader::Vertex, ":/shaders/metavoxel_point.vert"); _program.link(); _pointScaleLocation = _program.uniformLocation("pointScale"); diff --git a/interface/src/PieMenu.cpp b/interface/src/PieMenu.cpp index d62d0447e1..1a6b775f01 100644 --- a/interface/src/PieMenu.cpp +++ b/interface/src/PieMenu.cpp @@ -25,7 +25,6 @@ PieMenu::PieMenu() : void PieMenu::init(const char *fileName, int screenWidth, int screenHeight) { // Load SVG - switchToResourcesParentIfRequired(); QSvgRenderer renderer((QString) QString(fileName)); // Prepare a QImage with desired characteritisc diff --git a/interface/src/VoxelSystem.cpp b/interface/src/VoxelSystem.cpp index 1d5a238622..df0147250f 100644 --- a/interface/src/VoxelSystem.cpp +++ b/interface/src/VoxelSystem.cpp @@ -496,16 +496,15 @@ void VoxelSystem::initVoxelMemory() { // create our simple fragment shader if we're the first system to init if (!_perlinModulateProgram.isLinked()) { - switchToResourcesParentIfRequired(); - _perlinModulateProgram.addShaderFromSourceFile(QGLShader::Vertex, "resources/shaders/perlin_modulate.vert"); - _perlinModulateProgram.addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/perlin_modulate.frag"); + _perlinModulateProgram.addShaderFromSourceFile(QGLShader::Vertex, ":/shaders/perlin_modulate.vert"); + _perlinModulateProgram.addShaderFromSourceFile(QGLShader::Fragment, ":/shaders/perlin_modulate.frag"); _perlinModulateProgram.link(); _perlinModulateProgram.bind(); _perlinModulateProgram.setUniformValue("permutationNormalTexture", 0); _perlinModulateProgram.release(); - _shadowMapProgram.addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/shadow_map.frag"); + _shadowMapProgram.addShaderFromSourceFile(QGLShader::Fragment, ":/shaders/shadow_map.frag"); _shadowMapProgram.link(); _shadowMapProgram.bind(); diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 389791e89b..5d01c2acbf 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -577,13 +577,13 @@ bool Avatar::findParticleCollisions(const glm::vec3& particleCenter, float parti void Avatar::setFaceModelURL(const QUrl& faceModelURL) { AvatarData::setFaceModelURL(faceModelURL); - const QUrl DEFAULT_FACE_MODEL_URL = QUrl::fromLocalFile("resources/meshes/defaultAvatar_head.fst"); + const QUrl DEFAULT_FACE_MODEL_URL = QUrl::fromLocalFile(":/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("resources/meshes/defaultAvatar_body.fst"); + const QUrl DEFAULT_SKELETON_MODEL_URL = QUrl::fromLocalFile(":/meshes/defaultAvatar_body.fst"); _skeletonModel.setURL(_skeletonModelURL, DEFAULT_SKELETON_MODEL_URL, true, !isMyAvatar()); } diff --git a/interface/src/devices/OculusManager.cpp b/interface/src/devices/OculusManager.cpp index 65c0d9332f..099f195eac 100644 --- a/interface/src/devices/OculusManager.cpp +++ b/interface/src/devices/OculusManager.cpp @@ -57,8 +57,7 @@ void OculusManager::connect() { _hmdDevice->GetDeviceInfo(&info); _stereoConfig.SetHMDInfo(info); - switchToResourcesParentIfRequired(); - _program.addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/oculus.frag"); + _program.addShaderFromSourceFile(QGLShader::Fragment, ":/shaders/oculus.frag"); _program.link(); _textureLocation = _program.uniformLocation("texture"); diff --git a/interface/src/devices/Visage.cpp b/interface/src/devices/Visage.cpp index f9d3f89552..05607f9ab8 100644 --- a/interface/src/devices/Visage.cpp +++ b/interface/src/devices/Visage.cpp @@ -36,10 +36,9 @@ Visage::Visage() : _estimatedEyeYaw(0.0f) { #ifdef HAVE_VISAGE - switchToResourcesParentIfRequired(); - QByteArray licensePath = "resources/visage/license.vlc"; + QByteArray licensePath = ":/visage/license.vlc"; initializeLicenseManager(licensePath.data()); - _tracker = new VisageTracker2("resources/visage/Facial Features Tracker - Asymmetric.cfg"); + _tracker = new VisageTracker2(":/visage/Facial Features Tracker - Asymmetric.cfg"); if (_tracker->trackFromCam()) { _data = new FaceData(); diff --git a/interface/src/renderer/AmbientOcclusionEffect.cpp b/interface/src/renderer/AmbientOcclusionEffect.cpp index d6848453ec..51c92c9268 100644 --- a/interface/src/renderer/AmbientOcclusionEffect.cpp +++ b/interface/src/renderer/AmbientOcclusionEffect.cpp @@ -25,11 +25,10 @@ const int ROTATION_WIDTH = 4; const int ROTATION_HEIGHT = 4; void AmbientOcclusionEffect::init() { - switchToResourcesParentIfRequired(); _occlusionProgram = new ProgramObject(); - _occlusionProgram->addShaderFromSourceFile(QGLShader::Vertex, "resources/shaders/ambient_occlusion.vert"); - _occlusionProgram->addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/ambient_occlusion.frag"); + _occlusionProgram->addShaderFromSourceFile(QGLShader::Vertex, ":/shaders/ambient_occlusion.vert"); + _occlusionProgram->addShaderFromSourceFile(QGLShader::Fragment, ":/shaders/ambient_occlusion.frag"); _occlusionProgram->link(); // create the sample kernel: an array of spherically distributed offset vectors @@ -78,8 +77,8 @@ void AmbientOcclusionEffect::init() { glBindTexture(GL_TEXTURE_2D, 0); _blurProgram = new ProgramObject(); - _blurProgram->addShaderFromSourceFile(QGLShader::Vertex, "resources/shaders/ambient_occlusion.vert"); - _blurProgram->addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/occlusion_blur.frag"); + _blurProgram->addShaderFromSourceFile(QGLShader::Vertex, ":/shaders/ambient_occlusion.vert"); + _blurProgram->addShaderFromSourceFile(QGLShader::Fragment, ":/shaders/occlusion_blur.frag"); _blurProgram->link(); _blurProgram->bind(); diff --git a/interface/src/renderer/GlowEffect.cpp b/interface/src/renderer/GlowEffect.cpp index 967f803d61..707ec059e2 100644 --- a/interface/src/renderer/GlowEffect.cpp +++ b/interface/src/renderer/GlowEffect.cpp @@ -42,7 +42,7 @@ QOpenGLFramebufferObject* GlowEffect::getFreeFramebufferObject() const { static ProgramObject* createProgram(const QString& name) { ProgramObject* program = new ProgramObject(); - program->addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/" + name + ".frag"); + program->addShaderFromSourceFile(QGLShader::Fragment, ":/shaders/" + name + ".frag"); program->link(); program->bind(); @@ -57,8 +57,6 @@ void GlowEffect::init() { qDebug("[ERROR] GlowEffeect is already initialized."); return; } - - switchToResourcesParentIfRequired(); _addProgram = createProgram("glow_add"); _horizontalBlurProgram = createProgram("horizontal_blur"); diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index e1fede84d1..cfeda2d214 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -64,17 +64,16 @@ QVector Model::createJointStates(const FBXGeometry& geometry) void Model::init() { if (!_program.isLinked()) { - switchToResourcesParentIfRequired(); - _program.addShaderFromSourceFile(QGLShader::Vertex, "resources/shaders/model.vert"); - _program.addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/model.frag"); + _program.addShaderFromSourceFile(QGLShader::Vertex, ":/shaders/model.vert"); + _program.addShaderFromSourceFile(QGLShader::Fragment, ":/shaders/model.frag"); _program.link(); _program.bind(); _program.setUniformValue("texture", 0); _program.release(); - _normalMapProgram.addShaderFromSourceFile(QGLShader::Vertex, "resources/shaders/model_normal_map.vert"); - _normalMapProgram.addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/model_normal_map.frag"); + _normalMapProgram.addShaderFromSourceFile(QGLShader::Vertex, ":/shaders/model_normal_map.vert"); + _normalMapProgram.addShaderFromSourceFile(QGLShader::Fragment, ":/shaders/model_normal_map.frag"); _normalMapProgram.link(); _normalMapProgram.bind(); @@ -83,14 +82,14 @@ void Model::init() { _normalMapTangentLocation = _normalMapProgram.attributeLocation("tangent"); _normalMapProgram.release(); - _skinProgram.addShaderFromSourceFile(QGLShader::Vertex, "resources/shaders/skin_model.vert"); - _skinProgram.addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/model.frag"); + _skinProgram.addShaderFromSourceFile(QGLShader::Vertex, ":/shaders/skin_model.vert"); + _skinProgram.addShaderFromSourceFile(QGLShader::Fragment, ":/shaders/model.frag"); _skinProgram.link(); initSkinProgram(_skinProgram, _skinLocations); - _skinNormalMapProgram.addShaderFromSourceFile(QGLShader::Vertex, "resources/shaders/skin_model_normal_map.vert"); - _skinNormalMapProgram.addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/model_normal_map.frag"); + _skinNormalMapProgram.addShaderFromSourceFile(QGLShader::Vertex, ":/shaders/skin_model_normal_map.vert"); + _skinNormalMapProgram.addShaderFromSourceFile(QGLShader::Fragment, ":/shaders/model_normal_map.frag"); _skinNormalMapProgram.link(); initSkinProgram(_skinNormalMapProgram, _skinNormalMapLocations); diff --git a/interface/src/renderer/PointShader.cpp b/interface/src/renderer/PointShader.cpp index ed4225fbcd..6eb0b11212 100644 --- a/interface/src/renderer/PointShader.cpp +++ b/interface/src/renderer/PointShader.cpp @@ -29,7 +29,7 @@ PointShader::~PointShader() { ProgramObject* PointShader::createPointShaderProgram(const QString& name) { ProgramObject* program = new ProgramObject(); - program->addShaderFromSourceFile(QGLShader::Vertex, "resources/shaders/" + name + ".vert" ); + program->addShaderFromSourceFile(QGLShader::Vertex, ":/shaders/" + name + ".vert" ); program->link(); return program; } @@ -39,7 +39,6 @@ void PointShader::init() { qDebug("[ERROR] PointShader is already initialized."); return; } - switchToResourcesParentIfRequired(); _program = createPointShaderProgram("point_size"); _initialized = true; } diff --git a/interface/src/renderer/TextureCache.cpp b/interface/src/renderer/TextureCache.cpp index 1c58f93510..00b34b539b 100644 --- a/interface/src/renderer/TextureCache.cpp +++ b/interface/src/renderer/TextureCache.cpp @@ -106,7 +106,6 @@ GLuint TextureCache::getBlueTextureID() { GLuint TextureCache::getFileTextureID(const QString& filename) { GLuint id = _fileTextureIDs.value(filename); if (id == 0) { - switchToResourcesParentIfRequired(); QImage image = QImage(filename).convertToFormat(QImage::Format_ARGB32); glGenTextures(1, &id); diff --git a/interface/src/renderer/VoxelShader.cpp b/interface/src/renderer/VoxelShader.cpp index b630006b4b..56bb99b97f 100644 --- a/interface/src/renderer/VoxelShader.cpp +++ b/interface/src/renderer/VoxelShader.cpp @@ -29,8 +29,8 @@ VoxelShader::~VoxelShader() { ProgramObject* VoxelShader::createGeometryShaderProgram(const QString& name) { ProgramObject* program = new ProgramObject(); - program->addShaderFromSourceFile(QGLShader::Vertex, "resources/shaders/passthrough.vert" ); - program->addShaderFromSourceFile(QGLShader::Geometry, "resources/shaders/" + name + ".geom" ); + program->addShaderFromSourceFile(QGLShader::Vertex, ":/shaders/passthrough.vert" ); + program->addShaderFromSourceFile(QGLShader::Geometry, ":/shaders/" + name + ".geom" ); program->setGeometryInputType(GL_POINTS); program->setGeometryOutputType(GL_TRIANGLE_STRIP); const int VERTICES_PER_FACE = 4; @@ -46,7 +46,7 @@ void VoxelShader::init() { qDebug("[ERROR] TestProgram is already initialized."); return; } - switchToResourcesParentIfRequired(); + _program = createGeometryShaderProgram("voxel"); _initialized = true; } diff --git a/interface/src/ui/LogDialog.cpp b/interface/src/ui/LogDialog.cpp index 474b4f034e..f5d6d1d0da 100644 --- a/interface/src/ui/LogDialog.cpp +++ b/interface/src/ui/LogDialog.cpp @@ -36,8 +36,7 @@ LogDialog::LogDialog(QWidget* parent, AbstractLoggerInterface* logger) : QDialog setWindowTitle("Log"); setAttribute(Qt::WA_DeleteOnClose); - switchToResourcesParentIfRequired(); - QFile styleSheet("resources/styles/log_dialog.qss"); + QFile styleSheet(":/styles/log_dialog.qss"); if (styleSheet.open(QIODevice::ReadOnly)) { setStyleSheet(styleSheet.readAll()); } diff --git a/interface/src/ui/MetavoxelEditor.cpp b/interface/src/ui/MetavoxelEditor.cpp index 832c6b5d39..46fb7f166b 100644 --- a/interface/src/ui/MetavoxelEditor.cpp +++ b/interface/src/ui/MetavoxelEditor.cpp @@ -113,8 +113,8 @@ MetavoxelEditor::MetavoxelEditor() : if (_gridProgram.isLinked()) { return; } - switchToResourcesParentIfRequired(); - _gridProgram.addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/grid.frag"); + + _gridProgram.addShaderFromSourceFile(QGLShader::Fragment, ":/shaders/grid.frag"); _gridProgram.link(); } diff --git a/interface/src/ui/RearMirrorTools.cpp b/interface/src/ui/RearMirrorTools.cpp index b090987fa0..eaf26a21eb 100644 --- a/interface/src/ui/RearMirrorTools.cpp +++ b/interface/src/ui/RearMirrorTools.cpp @@ -23,12 +23,11 @@ RearMirrorTools::RearMirrorTools(QGLWidget* parent, QRect& bounds, QSettings* se _windowed(false), _fullScreen(false) { - _zoomLevel = HEAD, - switchToResourcesParentIfRequired(); - _closeTextureId = _parent->bindTexture(QImage("./resources/images/close.png")); - _resetTextureId = _parent->bindTexture(QImage("./resources/images/reset.png")); - _zoomHeadTextureId = _parent->bindTexture(QImage("./resources/images/head.png")); - _zoomBodyTextureId = _parent->bindTexture(QImage("./resources/images/body.png")); + _zoomLevel = HEAD; + _closeTextureId = _parent->bindTexture(QImage(":/images/close.png")); + _resetTextureId = _parent->bindTexture(QImage(":/images/reset.png")); + _zoomHeadTextureId = _parent->bindTexture(QImage(":/images/head.png")); + _zoomBodyTextureId = _parent->bindTexture(QImage(":/images/body.png")); _shrinkIconRect = QRect(ICON_PADDING, ICON_PADDING, ICON_SIZE, ICON_SIZE); _closeIconRect = QRect(_bounds.left() + ICON_PADDING, _bounds.top() + ICON_PADDING, ICON_SIZE, ICON_SIZE); diff --git a/libraries/shared/src/SharedUtil.cpp b/libraries/shared/src/SharedUtil.cpp index 2c531bab91..f80c56fd0c 100644 --- a/libraries/shared/src/SharedUtil.cpp +++ b/libraries/shared/src/SharedUtil.cpp @@ -198,21 +198,6 @@ bool isInEnvironment(const char* environment) { } } -void switchToResourcesParentIfRequired() { -#ifdef __APPLE__ - CFBundleRef mainBundle = CFBundleGetMainBundle(); - CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle); - char path[PATH_MAX]; - if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX)) { - // error! - } - CFRelease(resourcesURL); - - chdir(path); - chdir(".."); -#endif -} - void loadRandomIdentifier(unsigned char* identifierBuffer, int numBytes) { // seed the the random number generator srand(time(NULL)); diff --git a/libraries/shared/src/SharedUtil.h b/libraries/shared/src/SharedUtil.h index c18b2fca08..b08e0413a6 100644 --- a/libraries/shared/src/SharedUtil.h +++ b/libraries/shared/src/SharedUtil.h @@ -93,8 +93,6 @@ int getNthBit(unsigned char byte, int ordinal); /// determines the bit placement bool isInEnvironment(const char* environment); -void switchToResourcesParentIfRequired(); - void loadRandomIdentifier(unsigned char* identifierBuffer, int numBytes); const char* getCmdOption(int argc, const char * argv[],const char* option);