mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:27:04 +02:00
Fixed some coding standard issues
This commit is contained in:
parent
037550f176
commit
5ec9c5bb45
4 changed files with 40 additions and 42 deletions
|
@ -508,14 +508,12 @@ GLTexelFormat GLTexelFormat::evalGLTexelFormat(const Element& dstFormat, const E
|
||||||
case gpu::R11G11B10:
|
case gpu::R11G11B10:
|
||||||
texel.format = GL_RGB;
|
texel.format = GL_RGB;
|
||||||
texel.type = GL_UNSIGNED_INT_10F_11F_11F_REV;
|
texel.type = GL_UNSIGNED_INT_10F_11F_11F_REV;
|
||||||
// the type should be float
|
|
||||||
texel.internalFormat = GL_R11F_G11F_B10F;
|
texel.internalFormat = GL_R11F_G11F_B10F;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case gpu::RGB9E5:
|
case gpu::RGB9E5:
|
||||||
texel.format = GL_RGB;
|
texel.format = GL_RGB;
|
||||||
texel.type = GL_UNSIGNED_INT_5_9_9_9_REV;
|
texel.type = GL_UNSIGNED_INT_5_9_9_9_REV;
|
||||||
// the type should be float
|
|
||||||
texel.internalFormat = GL_RGB9_E5;
|
texel.internalFormat = GL_RGB9_E5;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -686,17 +686,17 @@ bool sphericalHarmonicsFromTexture(const gpu::Texture& cubeTexture, std::vector<
|
||||||
|
|
||||||
auto mipFormat = cubeTexture.getStoredMipFormat();
|
auto mipFormat = cubeTexture.getStoredMipFormat();
|
||||||
std::function<glm::vec3(uint32)> unpackFunc;
|
std::function<glm::vec3(uint32)> unpackFunc;
|
||||||
switch (mipFormat.getSemantic())
|
|
||||||
{
|
switch (mipFormat.getSemantic()) {
|
||||||
case gpu::R11G11B10:
|
case gpu::R11G11B10:
|
||||||
unpackFunc = glm::unpackF2x11_1x10;
|
unpackFunc = glm::unpackF2x11_1x10;
|
||||||
break;
|
break;
|
||||||
case gpu::RGB9E5:
|
case gpu::RGB9E5:
|
||||||
unpackFunc = glm::unpackF3x9_E1x5;
|
unpackFunc = glm::unpackF3x9_E1x5;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint sqOrder = order*order;
|
const uint sqOrder = order*order;
|
||||||
|
@ -732,7 +732,7 @@ bool sphericalHarmonicsFromTexture(const gpu::Texture& cubeTexture, std::vector<
|
||||||
for(int face=0; face < gpu::Texture::NUM_CUBE_FACES; face++) {
|
for(int face=0; face < gpu::Texture::NUM_CUBE_FACES; face++) {
|
||||||
PROFILE_RANGE(render_gpu, "ProcessFace");
|
PROFILE_RANGE(render_gpu, "ProcessFace");
|
||||||
|
|
||||||
auto data = (const uint32*)cubeTexture.accessStoredMipFace(0, face)->readData();
|
auto data = reinterpret_cast<const uint32*>( cubeTexture.accessStoredMipFace(0, face)->readData() );
|
||||||
if (data == nullptr) {
|
if (data == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -813,7 +813,7 @@ bool sphericalHarmonicsFromTexture(const gpu::Texture& cubeTexture, std::vector<
|
||||||
// index of texel in texture
|
// index of texel in texture
|
||||||
|
|
||||||
// get color from texture
|
// get color from texture
|
||||||
glm::vec3 color{ 0.f, 0.f, 0.f };
|
glm::vec3 color{ 0.0f, 0.0f, 0.0f };
|
||||||
for (int i = 0; i < stride; ++i) {
|
for (int i = 0; i < stride; ++i) {
|
||||||
for (int j = 0; j < stride; ++j) {
|
for (int j = 0; j < stride; ++j) {
|
||||||
int k = (int)(x + i - halfStride + (y + j - halfStride) * width);
|
int k = (int)(x + i - halfStride + (y + j - halfStride) * width);
|
||||||
|
|
|
@ -67,6 +67,10 @@ glm::uvec2 rectifyToSparseSize(const glm::uvec2& size) {
|
||||||
|
|
||||||
namespace image {
|
namespace image {
|
||||||
|
|
||||||
|
enum {
|
||||||
|
QIMAGE_HDR_FORMAT = QImage::Format_RGB30
|
||||||
|
};
|
||||||
|
|
||||||
TextureUsage::TextureLoader TextureUsage::getTextureLoaderForType(Type type, const QVariantMap& options) {
|
TextureUsage::TextureLoader TextureUsage::getTextureLoaderForType(Type type, const QVariantMap& options) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ALBEDO_TEXTURE:
|
case ALBEDO_TEXTURE:
|
||||||
|
@ -206,7 +210,7 @@ void setCubeTexturesCompressionEnabled(bool enabled) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static float denormalize(float value, const float minValue) {
|
static float denormalize(float value, const float minValue) {
|
||||||
return value < minValue ? 0.f : value;
|
return value < minValue ? 0.0f : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 packR11G11B10F(const glm::vec3& color) {
|
uint32 packR11G11B10F(const glm::vec3& color) {
|
||||||
|
@ -319,17 +323,18 @@ struct OutputHandler : public nvtt::OutputHandler {
|
||||||
_data = static_cast<gpu::Byte*>(malloc(size));
|
_data = static_cast<gpu::Byte*>(malloc(size));
|
||||||
_current = _data;
|
_current = _data;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool writeData(const void* data, int size) override {
|
virtual bool writeData(const void* data, int size) override {
|
||||||
assert(_current + size <= _data + _size);
|
assert(_current + size <= _data + _size);
|
||||||
memcpy(_current, data, size);
|
memcpy(_current, data, size);
|
||||||
_current += size;
|
_current += size;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void endImage() override {
|
virtual void endImage() override {
|
||||||
if (_face >= 0) {
|
if (_face >= 0) {
|
||||||
_texture->assignStoredMipFace(_miplevel, _face, _size, static_cast<const gpu::Byte*>(_data));
|
_texture->assignStoredMipFace(_miplevel, _face, _size, static_cast<const gpu::Byte*>(_data));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
_texture->assignStoredMip(_miplevel, _size, static_cast<const gpu::Byte*>(_data));
|
_texture->assignStoredMip(_miplevel, _size, static_cast<const gpu::Byte*>(_data));
|
||||||
}
|
}
|
||||||
free(_data);
|
free(_data);
|
||||||
|
@ -433,11 +438,11 @@ void generateHDRMips(gpu::Texture* texture, const QImage& image, int face) {
|
||||||
data.resize(width*height);
|
data.resize(width*height);
|
||||||
dataIt = data.begin();
|
dataIt = data.begin();
|
||||||
for (auto lineNb = 0; lineNb < height; lineNb++) {
|
for (auto lineNb = 0; lineNb < height; lineNb++) {
|
||||||
const uint32* srcPixelIt = (const uint32*)image.constScanLine(lineNb);
|
const uint32* srcPixelIt = reinterpret_cast<const uint32*>( image.constScanLine(lineNb) );
|
||||||
const uint32* srcPixelEnd = srcPixelIt + width;
|
const uint32* srcPixelEnd = srcPixelIt + width;
|
||||||
|
|
||||||
while (srcPixelIt < srcPixelEnd) {
|
while (srcPixelIt < srcPixelEnd) {
|
||||||
*dataIt = glm::vec4(unpackFunc(*srcPixelIt), 1.f);
|
*dataIt = glm::vec4(unpackFunc(*srcPixelIt), 1.0f);
|
||||||
++srcPixelIt;
|
++srcPixelIt;
|
||||||
++dataIt;
|
++dataIt;
|
||||||
}
|
}
|
||||||
|
@ -446,7 +451,7 @@ void generateHDRMips(gpu::Texture* texture, const QImage& image, int face) {
|
||||||
|
|
||||||
nvtt::OutputOptions outputOptions;
|
nvtt::OutputOptions outputOptions;
|
||||||
outputOptions.setOutputHeader(false);
|
outputOptions.setOutputHeader(false);
|
||||||
std::auto_ptr<nvtt::OutputHandler> outputHandler;
|
std::unique_ptr<nvtt::OutputHandler> outputHandler;
|
||||||
MyErrorHandler errorHandler;
|
MyErrorHandler errorHandler;
|
||||||
outputOptions.setErrorHandler(&errorHandler);
|
outputOptions.setErrorHandler(&errorHandler);
|
||||||
nvtt::Context context;
|
nvtt::Context context;
|
||||||
|
@ -1086,29 +1091,29 @@ QImage convertToHDRFormat(QImage srcImage, gpu::Element format) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (format.getSemantic()) {
|
switch (format.getSemantic()) {
|
||||||
case gpu::R11G11B10:
|
case gpu::R11G11B10:
|
||||||
packFunc = packR11G11B10F;
|
packFunc = packR11G11B10F;
|
||||||
#ifdef DEBUG_COLOR_PACKING
|
#ifdef DEBUG_COLOR_PACKING
|
||||||
unpackFunc = glm::unpackF2x11_1x10;
|
unpackFunc = glm::unpackF2x11_1x10;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case gpu::RGB9E5:
|
case gpu::RGB9E5:
|
||||||
packFunc = glm::packF3x9_E1x5;
|
packFunc = glm::packF3x9_E1x5;
|
||||||
#ifdef DEBUG_COLOR_PACKING
|
#ifdef DEBUG_COLOR_PACKING
|
||||||
unpackFunc = glm::unpackF3x9_E1x5;
|
unpackFunc = glm::unpackF3x9_E1x5;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qCWarning(imagelogging) << "Unsupported HDR format";
|
qCWarning(imagelogging) << "Unsupported HDR format";
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
return srcImage;
|
return srcImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
srcImage = srcImage.convertToFormat(QImage::Format_ARGB32);
|
srcImage = srcImage.convertToFormat(QImage::Format_ARGB32);
|
||||||
for (auto y = 0; y < srcImage.height(); y++) {
|
for (auto y = 0; y < srcImage.height(); y++) {
|
||||||
const QRgb* srcLineIt = (const QRgb*) srcImage.constScanLine(y);
|
const QRgb* srcLineIt = reinterpret_cast<const QRgb*>( srcImage.constScanLine(y) );
|
||||||
const QRgb* srcLineEnd = srcLineIt + srcImage.width();
|
const QRgb* srcLineEnd = srcLineIt + srcImage.width();
|
||||||
uint32* hdrLineIt = (uint32*) hdrImage.scanLine(y);
|
uint32* hdrLineIt = reinterpret_cast<uint32*>( hdrImage.scanLine(y) );
|
||||||
glm::vec3 color;
|
glm::vec3 color;
|
||||||
|
|
||||||
while (srcLineIt < srcLineEnd) {
|
while (srcLineIt < srcLineEnd) {
|
||||||
|
@ -1116,7 +1121,7 @@ QImage convertToHDRFormat(QImage srcImage, gpu::Element format) {
|
||||||
color.g = qGreen(*srcLineIt);
|
color.g = qGreen(*srcLineIt);
|
||||||
color.b = qBlue(*srcLineIt);
|
color.b = qBlue(*srcLineIt);
|
||||||
// Normalize and apply gamma
|
// Normalize and apply gamma
|
||||||
color /= 255.f;
|
color /= 255.0f;
|
||||||
color.r = powf(color.r, 2.2f);
|
color.r = powf(color.r, 2.2f);
|
||||||
color.g = powf(color.g, 2.2f);
|
color.g = powf(color.g, 2.2f);
|
||||||
color.b = powf(color.b, 2.2f);
|
color.b = powf(color.b, 2.2f);
|
||||||
|
|
|
@ -13,11 +13,11 @@
|
||||||
#define hifi_image_Image_h
|
#define hifi_image_Image_h
|
||||||
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QImage>
|
|
||||||
|
|
||||||
#include <gpu/Texture.h>
|
#include <gpu/Texture.h>
|
||||||
|
|
||||||
class QByteArray;
|
class QByteArray;
|
||||||
|
class QImage;
|
||||||
|
|
||||||
namespace image {
|
namespace image {
|
||||||
|
|
||||||
|
@ -74,11 +74,6 @@ void setNormalTexturesCompressionEnabled(bool enabled);
|
||||||
void setGrayscaleTexturesCompressionEnabled(bool enabled);
|
void setGrayscaleTexturesCompressionEnabled(bool enabled);
|
||||||
void setCubeTexturesCompressionEnabled(bool enabled);
|
void setCubeTexturesCompressionEnabled(bool enabled);
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
QIMAGE_HDR_FORMAT = QImage::Format_RGB30
|
|
||||||
};
|
|
||||||
|
|
||||||
gpu::TexturePointer processImage(const QByteArray& content, const std::string& url, int maxNumPixels, TextureUsage::Type textureType);
|
gpu::TexturePointer processImage(const QByteArray& content, const std::string& url, int maxNumPixels, TextureUsage::Type textureType);
|
||||||
|
|
||||||
} // namespace image
|
} // namespace image
|
||||||
|
|
Loading…
Reference in a new issue