Showing the changes to libraries/render-utils/src/TextureCache.cpp (1 of 5 files). Show all
Unified · Split
| @@ -524,10 +524,37 @@ void NetworkTexture::setImage(const QImage& image, bool translucent, const QColo · 523 unmodified lines | ||
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | if (_type == CUBE_TEXTURE) { |
| 527 | − if (_height >= (6 * _width)) { | |
| 528 | − _gpuTexture = gpu::TexturePointer(gpu::Texture::createCube(formatGPU, image.width(), gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR, gpu::Sampler::WRAP_CLAMP))); | |
| 529 | − _gpuTexture->assignStoredMip(0, formatMip, image.byteCount(), image.constBits()); | |
| 530 | − _gpuTexture->autoGenerateMips(-1); | |
| 527 | + _gpuTexture = gpu::TexturePointer(gpu::Texture::createCube(formatGPU, image.width(), gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR, gpu::Sampler::WRAP_CLAMP))); | |
| 528 | + _gpuTexture->autoGenerateMips(-1); | |
| 529 | + | |
| 530 | + std::vector<QImage> faces; | |
| 531 | + if (_height == (6 * _width)) { | |
| 532 | + int faceWidth = _width; | |
| 533 | + | |
| 534 | + faces.push_back(image.copy(QRect(0, 0 * faceWidth, faceWidth, faceWidth))); | |
| 535 | + faces.push_back(image.copy(QRect(0, 1 * faceWidth, faceWidth, faceWidth))); | |
| 536 | + faces.push_back(image.copy(QRect(0, 2 * faceWidth, faceWidth, faceWidth))); | |
| 537 | + faces.push_back(image.copy(QRect(0, 3 * faceWidth, faceWidth, faceWidth))); | |
| 538 | + faces.push_back(image.copy(QRect(0, 4 * faceWidth, faceWidth, faceWidth))); | |
| 539 | + faces.push_back(image.copy(QRect(0, 5 * faceWidth, faceWidth, faceWidth))); | |
| 540 | + } else if ((_height / 3) == (_width / 4)) { | |
| 541 | + int faceWidth = _height / 3; | |
| 542 | + faces.push_back(image.copy(QRect(2 * faceWidth, faceWidth, faceWidth, faceWidth))); | |
| 543 | + faces.push_back(image.copy(QRect(0 * faceWidth, faceWidth, faceWidth, faceWidth))); | |
| 544 | + | |
| 545 | + faces.push_back(image.copy(QRect(1 * faceWidth, 0, faceWidth, faceWidth))); | |
| 546 | + faces.push_back(image.copy(QRect(1 * faceWidth, 0 * faceWidth, faceWidth, faceWidth))); | |
| 547 | + | |
| 548 | + faces.push_back(image.copy(QRect(3 * faceWidth, faceWidth, faceWidth, faceWidth))); | |
| 549 | + faces.push_back(image.copy(QRect(1 * faceWidth, faceWidth, faceWidth, faceWidth))); | |
| 550 | + } | |
| 551 | + | |
| 552 | + if (faces.size() == _gpuTexture->getNumFaces()) { | |
| 553 | + int f = 0; | |
| 554 | + for (auto& face : faces) { | |
| 555 | + _gpuTexture->assignStoredMipFace(0, formatMip, face.byteCount(), face.constBits(), f); | |
| 556 | + f++; | |
| 557 | + } | |
| 531 | 558 | } |
| 532 | 559 | } else { |
| 533 | 560 | _gpuTexture = gpu::TexturePointer(gpu::Texture::create2D(formatGPU, image.width(), image.height(), gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR))); |