History

refactoring th ecube texure loading to support 2 different layouts

Sam Gateau committed 11 years ago

Commit f1fcce31 parent 9c271065 files · +222 −128Browse files

Showing the changes to libraries/render-utils/src/TextureCache.cpp (1 of 5 files). Show all

Unified · Split

libraries/render-utils/src/TextureCache.cpp+31−4
@@ -524,10 +524,37 @@ void NetworkTexture::setImage(const QImage& image, bool translucent, const QColo · 523 unmodified lines
524 }524 }
525 525
526 if (_type == CUBE_TEXTURE) {526 if (_type == CUBE_TEXTURE) {
527 if (_height >= (6 * _width)) {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 = 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 _gpuTexture->assignStoredMip(0, formatMip, image.byteCount(), image.constBits());529
530 _gpuTexture->autoGenerateMips(-1);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 } else {559 } else {
533 _gpuTexture = gpu::TexturePointer(gpu::Texture::create2D(formatGPU, image.width(), image.height(), gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR)));560 _gpuTexture = gpu::TexturePointer(gpu::Texture::create2D(formatGPU, image.width(), image.height(), gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR)));

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t