From edf0ca2b06e4621afc82db46945d8d5c3fcee474 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Tue, 31 Mar 2015 10:29:03 -0700 Subject: [PATCH 01/11] Forbifd the global ambient lighting to go the simple global value and instead fallback to the first Spherical harmonics preset --- libraries/render-utils/src/DeferredLightingEffect.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index ffa84adbdf..6ed73c6750 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -535,10 +535,14 @@ void DeferredLightingEffect::loadLightProgram(const char* fragSource, bool limit } void DeferredLightingEffect::setAmbientLightMode(int preset) { - if ((preset >= -1) && (preset < model::SphericalHarmonics::NUM_PRESET)) { + //if ((preset >= -1) && (preset < model::SphericalHarmonics::NUM_PRESET)) { + if ((preset >= 0) && (preset < model::SphericalHarmonics::NUM_PRESET)) { _ambientLightMode = preset; auto light = _allocatedLights.front(); light->setAmbientSpherePreset(model::SphericalHarmonics::Preset(preset % model::SphericalHarmonics::NUM_PRESET)); + } else { + // force to preset 0 + setAmbientLightMode(0); } } From 347ef3c4e1de32bca0afffa6db9ef09cd0270da3 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 31 Mar 2015 14:03:37 -0700 Subject: [PATCH 02/11] use scaling from visual model on collision model rather than using the bounds from the collision model --- .../src/RenderableModelEntityItem.cpp | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index 2b65081185..2387e729ce 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -293,7 +293,7 @@ bool RenderableModelEntityItem::isReadyToComputeShape() { } if (_model->getCollisionURL().isEmpty()) { - // no model url, so we're ready to compute a shape. + // no collision-model url, so we're ready to compute a shape (of type None). return true; } @@ -312,15 +312,17 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) { info.setParams(getShapeType(), 0.5f * getDimensions()); } else { const QSharedPointer collisionNetworkGeometry = _model->getCollisionGeometry(); - const FBXGeometry& fbxGeometry = collisionNetworkGeometry->getFBXGeometry(); + const FBXGeometry& collisionGeometry = collisionNetworkGeometry->getFBXGeometry(); + + const QSharedPointer renderNetworkGeometry = _model->getGeometry(); + const FBXGeometry& renderGeometry = renderNetworkGeometry->getFBXGeometry(); - AABox aaBox; _points.clear(); unsigned int i = 0; // the way OBJ files get read, each section under a "g" line is its own meshPart. We only expect // to find one actual "mesh" (with one or more meshParts in it), but we loop over the meshes, just in case. - foreach (const FBXMesh& mesh, fbxGeometry.meshes) { + foreach (const FBXMesh& mesh, collisionGeometry.meshes) { // each meshPart is a convex hull foreach (const FBXMeshPart &meshPart, mesh.parts) { QVector pointsInPart; @@ -332,15 +334,9 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) { unsigned int p0Index = meshPart.triangleIndices[j*3]; unsigned int p1Index = meshPart.triangleIndices[j*3+1]; unsigned int p2Index = meshPart.triangleIndices[j*3+2]; - assert(p0Index < (unsigned int)mesh.vertices.size()); - assert(p1Index < (unsigned int)mesh.vertices.size()); - assert(p2Index < (unsigned int)mesh.vertices.size()); glm::vec3 p0 = mesh.vertices[p0Index]; glm::vec3 p1 = mesh.vertices[p1Index]; glm::vec3 p2 = mesh.vertices[p2Index]; - aaBox += p0; - aaBox += p1; - aaBox += p2; if (!pointsInPart.contains(p0)) { pointsInPart << p0; } @@ -360,18 +356,10 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) { unsigned int p1Index = meshPart.quadIndices[j*4+1]; unsigned int p2Index = meshPart.quadIndices[j*4+2]; unsigned int p3Index = meshPart.quadIndices[j*4+3]; - assert(p0Index < (unsigned int)mesh.vertices.size()); - assert(p1Index < (unsigned int)mesh.vertices.size()); - assert(p2Index < (unsigned int)mesh.vertices.size()); - assert(p3Index < (unsigned int)mesh.vertices.size()); glm::vec3 p0 = mesh.vertices[p0Index]; glm::vec3 p1 = mesh.vertices[p1Index]; glm::vec3 p2 = mesh.vertices[p2Index]; glm::vec3 p3 = mesh.vertices[p3Index]; - aaBox += p0; - aaBox += p1; - aaBox += p2; - aaBox += p3; if (!pointsInPart.contains(p0)) { pointsInPart << p0; } @@ -386,6 +374,11 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) { } } + if (pointsInPart.size() == 0) { + qDebug() << "Warning -- meshPart has no faces"; + continue; + } + // add next convex hull QVector newMeshPoints; _points << newMeshPoints; @@ -394,11 +387,14 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) { } } - // make sure we aren't about to divide by zero - glm::vec3 aaBoxDim = aaBox.getDimensions(); - aaBoxDim = glm::clamp(aaBoxDim, glm::vec3(FLT_EPSILON), aaBoxDim); + // We expect that the collision model will have the same units and will be displaced + // from it's origin in the same way the visual model is. The visual model has + // been centered and probably scaled. We take the scaling and offset which were applied + // to the visual model and apply them to the collision model (without regard for the + // collision model's extents). + + glm::vec3 scale = _dimensions / renderGeometry.getUnscaledMeshExtents().size(); - glm::vec3 scale = _dimensions / aaBoxDim; // multiply each point by scale before handing the point-set off to the physics engine for (int i = 0; i < _points.size(); i++) { for (int j = 0; j < _points[i].size(); j++) { From 9e0118492ebd57490be55863d74a2eedbc8fe159 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 31 Mar 2015 14:04:21 -0700 Subject: [PATCH 03/11] make sure to not leave in-use resources in UnusedResource list --- libraries/networking/src/ResourceCache.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/libraries/networking/src/ResourceCache.cpp b/libraries/networking/src/ResourceCache.cpp index 739e587f5f..97ae8e1ae2 100644 --- a/libraries/networking/src/ResourceCache.cpp +++ b/libraries/networking/src/ResourceCache.cpp @@ -70,6 +70,7 @@ QSharedPointer ResourceCache::getResource(const QUrl& url, const QUrl& bool delayLoad, void* extra) { QSharedPointer resource = _resources.value(url); if (!resource.isNull()) { + removeUnusedResource(resource); return resource; } @@ -83,16 +84,14 @@ QSharedPointer ResourceCache::getResource(const QUrl& url, const QUrl& return getResource(fallback, QUrl(), delayLoad); } - if (resource.isNull()) { - resource = createResource(url, fallback.isValid() ? - getResource(fallback, QUrl(), true) : QSharedPointer(), delayLoad, extra); - resource->setSelf(resource); - resource->setCache(this); - _resources.insert(url, resource); - - } else { - removeUnusedResource(resource); - } + resource = createResource(url, fallback.isValid() ? + getResource(fallback, QUrl(), true) : QSharedPointer(), delayLoad, extra); + resource->setSelf(resource); + resource->setCache(this); + _resources.insert(url, resource); + removeUnusedResource(resource); + resource->ensureLoading(); + return resource; } From ea2c5ff6226f23c83180cc4d14dadc1a4dde81a2 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 31 Mar 2015 14:04:33 -0700 Subject: [PATCH 04/11] formatting --- libraries/render-utils/src/GeometryCache.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index c74f714e8d..98843cc87f 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -1775,10 +1775,10 @@ QSharedPointer GeometryCache::getGeometry(const QUrl& url, cons return getResource(url, fallback, delayLoad, NULL).staticCast(); } -QSharedPointer GeometryCache::createResource(const QUrl& url, - const QSharedPointer& fallback, bool delayLoad, const void* extra) { +QSharedPointer GeometryCache::createResource(const QUrl& url, const QSharedPointer& fallback, + bool delayLoad, const void* extra) { QSharedPointer geometry(new NetworkGeometry(url, fallback.staticCast(), delayLoad), - &Resource::allReferencesCleared); + &Resource::allReferencesCleared); geometry->setLODParent(geometry); return geometry.staticCast(); } From 55d506bb53c7a4f9ab1974a8cd6099954b53afd6 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 31 Mar 2015 14:04:49 -0700 Subject: [PATCH 05/11] formatting --- libraries/shared/src/Extents.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/shared/src/Extents.h b/libraries/shared/src/Extents.h index 66b33114f7..024d72013a 100644 --- a/libraries/shared/src/Extents.h +++ b/libraries/shared/src/Extents.h @@ -48,7 +48,7 @@ public: void rotate(const glm::quat& rotation); glm::vec3 size() const { return maximum - minimum; } - float largestDimension () const {glm::vec3 s = size(); return glm::max(s[0], s[1], s[2]); } + float largestDimension() const {glm::vec3 s = size(); return glm::max(s[0], s[1], s[2]); } /// \return new Extents which is original rotated around orign by rotation Extents getRotated(const glm::quat& rotation) const { From f4695643e3eb2f1ab8600d10621b973470eb7373 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Tue, 31 Mar 2015 14:13:19 -0700 Subject: [PATCH 06/11] Blocks fall when made, better edge colors --- examples/blocks.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/examples/blocks.js b/examples/blocks.js index 30c2126096..7bc52824db 100644 --- a/examples/blocks.js +++ b/examples/blocks.js @@ -43,8 +43,8 @@ var floor = Entities.addEntity( var edge1 = Entities.addEntity( { type: "Box", position: Vec3.sum(center, { x: FLOOR_SIZE / 2.0, y: FLOOR_THICKNESS / 2.0, z: 0 }), - dimensions: { x: EDGE_THICKESS, y: EDGE_THICKESS, z: FLOOR_SIZE }, - color: { red: 128, green: 128, blue: 128 }, + dimensions: { x: EDGE_THICKESS, y: EDGE_THICKESS, z: FLOOR_SIZE + EDGE_THICKESS }, + color: { red: 100, green: 100, blue: 100 }, gravity: { x: 0, y: 0, z: 0 }, ignoreCollisions: false, visible: true, @@ -54,8 +54,8 @@ var edge1 = Entities.addEntity( var edge2 = Entities.addEntity( { type: "Box", position: Vec3.sum(center, { x: -FLOOR_SIZE / 2.0, y: FLOOR_THICKNESS / 2.0, z: 0 }), - dimensions: { x: EDGE_THICKESS, y: EDGE_THICKESS, z: FLOOR_SIZE }, - color: { red: 128, green: 128, blue: 128 }, + dimensions: { x: EDGE_THICKESS, y: EDGE_THICKESS, z: FLOOR_SIZE + EDGE_THICKESS }, + color: { red: 100, green: 100, blue: 100 }, gravity: { x: 0, y: 0, z: 0 }, ignoreCollisions: false, visible: true, @@ -65,8 +65,8 @@ var edge2 = Entities.addEntity( var edge3 = Entities.addEntity( { type: "Box", position: Vec3.sum(center, { x: 0, y: FLOOR_THICKNESS / 2.0, z: -FLOOR_SIZE / 2.0 }), - dimensions: { x: FLOOR_SIZE, y: EDGE_THICKESS, z: EDGE_THICKESS }, - color: { red: 128, green: 128, blue: 128 }, + dimensions: { x: FLOOR_SIZE + EDGE_THICKESS, y: EDGE_THICKESS, z: EDGE_THICKESS }, + color: { red: 100, green: 100, blue: 100 }, gravity: { x: 0, y: 0, z: 0 }, ignoreCollisions: false, visible: true, @@ -76,8 +76,8 @@ var edge3 = Entities.addEntity( var edge4 = Entities.addEntity( { type: "Box", position: Vec3.sum(center, { x: 0, y: FLOOR_THICKNESS / 2.0, z: FLOOR_SIZE / 2.0 }), - dimensions: { x: FLOOR_SIZE, y: EDGE_THICKESS, z: EDGE_THICKESS }, - color: { red: 128, green: 128, blue: 128 }, + dimensions: { x: FLOOR_SIZE + EDGE_THICKESS, y: EDGE_THICKESS, z: EDGE_THICKESS }, + color: { red: 100, green: 100, blue: 100 }, gravity: { x: 0, y: 0, z: 0 }, ignoreCollisions: false, visible: true, @@ -97,6 +97,7 @@ for (var i = 0; i < NUM_BLOCKS; i++) { dimensions: { x: type.x * SCALE, y: type.y * SCALE, z: type.z * SCALE }, color: { red: type.red, green: type.green, blue: type.blue }, gravity: { x: 0, y: GRAVITY, z: 0 }, + velocity: { x: 0, y: 0.05, z: 0 }, ignoreCollisions: false, damping: DAMPING, lifetime: LIFETIME, @@ -104,6 +105,11 @@ for (var i = 0; i < NUM_BLOCKS; i++) { } function scriptEnding() { + Entities.editEntity(edge1, { locked: false }); + Entities.editEntity(edge2, { locked: false }); + Entities.editEntity(edge3, { locked: false }); + Entities.editEntity(edge4, { locked: false }); + Entities.editEntity(floor, { locked: false }); Entities.deleteEntity(edge1); Entities.deleteEntity(edge2); Entities.deleteEntity(edge3); From 95cc8672c016e1a78c829dc7c055212de43607ab Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 31 Mar 2015 14:32:43 -0700 Subject: [PATCH 07/11] remove unneeded assert --- libraries/entities-renderer/src/RenderableModelEntityItem.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index 2387e729ce..db742be8a1 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -329,7 +329,6 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) { // run through all the triangles and (uniquely) add each point to the hull unsigned int triangleCount = meshPart.triangleIndices.size() / 3; - assert((unsigned int)meshPart.triangleIndices.size() == triangleCount*3); for (unsigned int j = 0; j < triangleCount; j++) { unsigned int p0Index = meshPart.triangleIndices[j*3]; unsigned int p1Index = meshPart.triangleIndices[j*3+1]; From 48144a46b1f4de9fd1c008cf6949a11095de59d0 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 31 Mar 2015 14:34:35 -0700 Subject: [PATCH 08/11] don't keep empty mesh-parts. take units hint from a common first-line comment, if it's there. --- libraries/fbx/src/OBJReader.cpp | 55 +++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/libraries/fbx/src/OBJReader.cpp b/libraries/fbx/src/OBJReader.cpp index db2733f27b..c87a942baa 100644 --- a/libraries/fbx/src/OBJReader.cpp +++ b/libraries/fbx/src/OBJReader.cpp @@ -27,7 +27,8 @@ public: enum SpecialToken { NO_TOKEN = -1, NO_PUSHBACKED_TOKEN = -1, - DATUM_TOKEN = 0x100 + DATUM_TOKEN = 0x100, + COMMENT_TOKEN = 0x101 }; int nextToken(); const QByteArray& getDatum() const { return _datum; } @@ -35,11 +36,13 @@ public: void skipLine() { _device->readLine(); } void pushBackToken(int token) { _pushedBackToken = token; } void ungetChar(char ch) { _device->ungetChar(ch); } + const QString getComment() const { return _comment; } private: QIODevice* _device; QByteArray _datum; int _pushedBackToken; + QString _comment; }; @@ -56,9 +59,11 @@ int OBJTokenizer::nextToken() { continue; // skip whitespace } switch (ch) { - case '#': - _device->readLine(); // skip the comment - break; + case '#': { + _comment = _device->readLine(); // skip the comment + qDebug() << "COMMENT:" << _comment; + return COMMENT_TOKEN; + } case '\"': _datum = ""; @@ -104,7 +109,8 @@ bool OBJTokenizer::isNextTokenFloat() { } bool parseOBJGroup(OBJTokenizer &tokenizer, const QVariantHash& mapping, - FBXGeometry &geometry, QVector& faceNormals, QVector& faceNormalIndexes) { + FBXGeometry &geometry, QVector& faceNormals, QVector& faceNormalIndexes, + float& scaleGuess) { FBXMesh &mesh = geometry.meshes[0]; mesh.parts.append(FBXMeshPart()); FBXMeshPart &meshPart = mesh.parts.last(); @@ -128,7 +134,17 @@ bool parseOBJGroup(OBJTokenizer &tokenizer, const QVariantHash& mapping, meshPart._material->setEmissive(glm::vec3(0.0, 0.0, 0.0)); while (true) { - if (tokenizer.nextToken() != OBJTokenizer::DATUM_TOKEN) { + int tokenType = tokenizer.nextToken(); + if (tokenType == OBJTokenizer::COMMENT_TOKEN) { + if (tokenizer.getComment().contains("This file uses centimeters as units")) { + scaleGuess = 1.0f / 100.0f; + } + if (tokenizer.getComment().contains("This file uses millimeters as units")) { + scaleGuess = 1.0f / 1000.0f; + } + continue; + } + if (tokenType != OBJTokenizer::DATUM_TOKEN) { result = false; break; } @@ -192,6 +208,7 @@ bool parseOBJGroup(OBJTokenizer &tokenizer, const QVariantHash& mapping, while (true) { if (tokenizer.nextToken() != OBJTokenizer::DATUM_TOKEN) { if (indices.count() == 0) { + // nonsense, bail out. goto done; } break; @@ -266,22 +283,22 @@ bool parseOBJGroup(OBJTokenizer &tokenizer, const QVariantHash& mapping, } } else { // something we don't (yet) care about - qDebug() << "OBJ parser is skipping a line with" << token; + // qDebug() << "OBJ parser is skipping a line with" << token; tokenizer.skipLine(); } } done: + + if (meshPart.triangleIndices.size() == 0 && meshPart.quadIndices.size() == 0) { + // empty mesh? + mesh.parts.pop_back(); + } + return result; } -FBXGeometry extractOBJGeometry(const FBXNode& node, const QVariantHash& mapping) { - FBXGeometry geometry; - return geometry; -} - - FBXGeometry readOBJ(const QByteArray& model, const QVariantHash& mapping) { QBuffer buffer(const_cast(&model)); buffer.open(QIODevice::ReadOnly); @@ -294,24 +311,30 @@ FBXGeometry readOBJ(QIODevice* device, const QVariantHash& mapping) { OBJTokenizer tokenizer(device); QVector faceNormalIndexes; QVector faceNormals; + float scaleGuess = 1.0f; faceNormalIndexes.clear(); geometry.meshExtents.reset(); geometry.meshes.append(FBXMesh()); - - try { // call parseOBJGroup as long as it's returning true. Each successful call will // add a new meshPart to the geometry's single mesh. bool success = true; while (success) { - success = parseOBJGroup(tokenizer, mapping, geometry, faceNormals, faceNormalIndexes); + success = parseOBJGroup(tokenizer, mapping, geometry, faceNormals, faceNormalIndexes, scaleGuess); } FBXMesh &mesh = geometry.meshes[0]; + // if we got a hint about units, scale all the points + if (scaleGuess != 1.0f) { + for (int i = 0; i < mesh.vertices.size(); i++) { + mesh.vertices[i] *= scaleGuess; + } + } + mesh.meshExtents.reset(); foreach (const glm::vec3& vertex, mesh.vertices) { mesh.meshExtents.addPoint(vertex); From af6ce8fb07e75b8ea97697f6385e83f9793934c7 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 31 Mar 2015 14:37:41 -0700 Subject: [PATCH 09/11] HERE COMES AN S --- .../entities-renderer/src/RenderableModelEntityItem.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index db742be8a1..2353a20e7d 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -61,7 +61,7 @@ void RenderableModelEntityItem::remapTextures() { } if (!_model->isLoadedWithTextures()) { - return; // nothing to do if the model has not yet loaded it's default textures + return; // nothing to do if the model has not yet loaded its default textures } if (!_originalTexturesRead && _model->isLoadedWithTextures()) { @@ -220,7 +220,7 @@ Model* RenderableModelEntityItem::getModel(EntityTreeRenderer* renderer) { // if we have a URL, then we will want to end up returning a model... if (!getModelURL().isEmpty()) { - // if we have a previously allocated model, but it's URL doesn't match + // if we have a previously allocated model, but its URL doesn't match // then we need to let our renderer update our model for us. if (_model && QUrl(getModelURL()) != _model->getURL()) { result = _model = _myRenderer->updateModel(_model, getModelURL(), getCollisionModelURL()); @@ -387,7 +387,7 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) { } // We expect that the collision model will have the same units and will be displaced - // from it's origin in the same way the visual model is. The visual model has + // from its origin in the same way the visual model is. The visual model has // been centered and probably scaled. We take the scaling and offset which were applied // to the visual model and apply them to the collision model (without regard for the // collision model's extents). From 74f04c0c8450fe8cff8cd406f3ab4a25ea0e12a3 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Tue, 31 Mar 2015 14:57:51 -0700 Subject: [PATCH 10/11] remove useless comment --- libraries/render-utils/src/DeferredLightingEffect.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index 6ed73c6750..f46bd689d4 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -535,7 +535,6 @@ void DeferredLightingEffect::loadLightProgram(const char* fragSource, bool limit } void DeferredLightingEffect::setAmbientLightMode(int preset) { - //if ((preset >= -1) && (preset < model::SphericalHarmonics::NUM_PRESET)) { if ((preset >= 0) && (preset < model::SphericalHarmonics::NUM_PRESET)) { _ambientLightMode = preset; auto light = _allocatedLights.front(); From b4d11e2eb5680a8f31d8207ac1c7ec23ff271e06 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Tue, 31 Mar 2015 15:18:59 -0700 Subject: [PATCH 11/11] Add the needed global variable exported to enable the nvidia gpu on optimus platform (laptops with intel integrated) also log the opengl version and gpu and driver used --- interface/src/Application.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index eb427737e1..83e26719db 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -136,6 +136,13 @@ #include "ui/StandAloneJSConsole.h" #include "ui/Stats.h" +// ON WIndows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU +#if defined(Q_OS_WIN) +extern "C" { + _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; +} +#endif + using namespace std; // Starfield information @@ -646,6 +653,11 @@ void Application::initializeGL() { } #endif + qDebug() << "GL Version: " << QString((const char*) glGetString(GL_VERSION)); + qDebug() << "GL Shader Language Version: " << QString((const char*) glGetString(GL_SHADING_LANGUAGE_VERSION)); + qDebug() << "GL Vendor: " << QString((const char*) glGetString(GL_VENDOR)); + qDebug() << "GL Renderer: " << QString((const char*) glGetString(GL_RENDERER)); + #ifdef WIN32 GLenum err = glewInit(); if (GLEW_OK != err) {