From 4592bdcb4fdc1675c1b171afeb5cbb36022892b2 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Tue, 27 Jan 2015 15:42:56 -0800 Subject: [PATCH] fixes after review by Brad --- libraries/gpu/src/gpu/GLBackend.h | 6 +-- libraries/gpu/src/gpu/GLBackendTexture.cpp | 39 ++++++++++--------- libraries/gpu/src/gpu/Texture.cpp | 27 +++++-------- .../render-utils/src/DeferredLighting.slh | 2 +- 4 files changed, 33 insertions(+), 41 deletions(-) diff --git a/libraries/gpu/src/gpu/GLBackend.h b/libraries/gpu/src/gpu/GLBackend.h index a3f3495853..1731701022 100644 --- a/libraries/gpu/src/gpu/GLBackend.h +++ b/libraries/gpu/src/gpu/GLBackend.h @@ -34,7 +34,7 @@ public: class GLBuffer { public: - Stamp _stamp; + Stamp _stamp; GLuint _buffer; GLuint _size; @@ -46,8 +46,8 @@ public: class GLTexture { public: - Stamp _storageStamp; - Stamp _contentStamp; + Stamp _storageStamp; + Stamp _contentStamp; GLuint _texture; GLuint _size; diff --git a/libraries/gpu/src/gpu/GLBackendTexture.cpp b/libraries/gpu/src/gpu/GLBackendTexture.cpp index 075fd7ad71..5003eadf89 100755 --- a/libraries/gpu/src/gpu/GLBackendTexture.cpp +++ b/libraries/gpu/src/gpu/GLBackendTexture.cpp @@ -50,8 +50,8 @@ public: default: qDebug() << "Unknown combination of texel format"; } + break; } - break; case gpu::VEC2: { texel.format = GL_RG; @@ -69,8 +69,8 @@ public: qDebug() << "Unknown combination of texel format"; } + break; } - break; case gpu::VEC3: { texel.format = GL_RGB; @@ -85,8 +85,9 @@ public: default: qDebug() << "Unknown combination of texel format"; } + + break; } - break; case gpu::VEC4: { texel.format = GL_RGBA; @@ -121,8 +122,8 @@ public: default: qDebug() << "Unknown combination of texel format"; } + break; } - break; default: qDebug() << "Unknown combination of texel format"; @@ -147,8 +148,9 @@ public: default: qDebug() << "Unknown combination of texel format"; } + + break; } - break; case gpu::VEC2: { texel.format = GL_RG; @@ -166,8 +168,8 @@ public: qDebug() << "Unknown combination of texel format"; } + break; } - break; case gpu::VEC3: { texel.format = GL_RGB; @@ -186,8 +188,8 @@ public: default: qDebug() << "Unknown combination of texel format"; } + break; } - break; case gpu::VEC4: { texel.format = GL_RGBA; @@ -209,8 +211,8 @@ public: default: qDebug() << "Unknown combination of texel format"; } + break; } - break; default: qDebug() << "Unknown combination of texel format"; @@ -304,8 +306,8 @@ void GLBackend::syncGPUObject(const Texture& texture) { object->_storageStamp = texture.getStamp(); object->_size = texture.getSize(); } + break; } - break; default: qDebug() << "GLBackend::syncGPUObject(const Texture&) case for Texture Type " << texture.getType() << " not supported"; } @@ -315,16 +317,15 @@ void GLBackend::syncGPUObject(const Texture& texture) { GLuint GLBackend::getTextureID(const TexturePointer& texture) { - if (texture) { - GLBackend::syncGPUObject(*texture); - GLTexture* object = Backend::getGPUObject(*texture); - if (object) { - return object->_texture; - } else { - return 0; - } - } else { + if (!texture) { return 0; - } + } + GLBackend::syncGPUObject(*texture); + GLTexture* object = Backend::getGPUObject(*texture); + if (object) { + return object->_texture; + } else { + return 0; + } } diff --git a/libraries/gpu/src/gpu/Texture.cpp b/libraries/gpu/src/gpu/Texture.cpp index 83e97bb3ae..d0779afb42 100755 --- a/libraries/gpu/src/gpu/Texture.cpp +++ b/libraries/gpu/src/gpu/Texture.cpp @@ -31,9 +31,8 @@ Stamp Texture::Storage::getStamp(uint16 level) const { PixelsPointer mip = getMip(level); if (mip) { return mip->_sysmem.getStamp(); - } else { - return 0; } + return 0; } void Texture::Storage::reset() { @@ -43,17 +42,15 @@ void Texture::Storage::reset() { Texture::PixelsPointer Texture::Storage::editMip(uint16 level) { if (level < _mips.size()) { return _mips[level]; - } else { - return PixelsPointer(); } + return PixelsPointer(); } const Texture::PixelsPointer Texture::Storage::getMip(uint16 level) const { if (level < _mips.size()) { return _mips[level]; - } else { - return PixelsPointer(); } + return PixelsPointer(); } bool Texture::Storage::isMipAvailable(uint16 level) const { @@ -277,49 +274,43 @@ uint16 Texture::getStoredMipWidth(uint16 level) const { PixelsPointer mip = accessStoredMip(level); if (mip && mip->_sysmem.getSize()) { return evalMipWidth(level); - } else { - return 0; } + return 0; } uint16 Texture::getStoredMipHeight(uint16 level) const { PixelsPointer mip = accessStoredMip(level); if (mip && mip->_sysmem.getSize()) { return evalMipHeight(level); - } else { - return 0; } + return 0; } uint16 Texture::getStoredMipDepth(uint16 level) const { PixelsPointer mip = accessStoredMip(level); if (mip && mip->_sysmem.getSize()) { return evalMipDepth(level); - } else { - return 0; } + return 0; } uint32 Texture::getStoredMipNumTexels(uint16 level) const { PixelsPointer mip = accessStoredMip(level); if (mip && mip->_sysmem.getSize()) { return evalMipWidth(level) * evalMipHeight(level) * evalMipDepth(level); - } else { - return 0; } + return 0; } uint32 Texture::getStoredMipSize(uint16 level) const { PixelsPointer mip = accessStoredMip(level); if (mip && mip->_sysmem.getSize()) { return evalMipWidth(level) * evalMipHeight(level) * evalMipDepth(level) * getTexelFormat().getSize(); - } else { - return 0; } + return 0; } -uint16 Texture::evalNumSamplesUsed(uint16 numSamplesTried) -{ +uint16 Texture::evalNumSamplesUsed(uint16 numSamplesTried) { uint16 sample = numSamplesTried; if (numSamplesTried <= 1) sample = 1; diff --git a/libraries/render-utils/src/DeferredLighting.slh b/libraries/render-utils/src/DeferredLighting.slh index 9e421c03c9..cd65fd1053 100755 --- a/libraries/render-utils/src/DeferredLighting.slh +++ b/libraries/render-utils/src/DeferredLighting.slh @@ -59,7 +59,7 @@ vec3 evalDirectionalColor(float shadowAttenuation, vec3 position, vec3 normal, v // Diffuse Lighting float diffuseDot = dot(normal, gl_LightSource[0].position.xyz); float facingLight = step(0.0, diffuseDot) * shadowAttenuation; - vec3 diffuseColor = diffuse * (/*gl_FrontLightModelProduct.sceneColor.rgb +*/ gl_FrontLightProduct[0].diffuse.rgb * (diffuseDot * facingLight)); + vec3 diffuseColor = diffuse * (gl_FrontLightProduct[0].diffuse.rgb * (diffuseDot * facingLight)); // compute the specular multiplier (sans exponent) float specularPower = facingLight * max(0.0,