mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 10:09:05 +02:00
Fix TextureCache not correctly choosing gl41 when gl45 is disabled
This commit is contained in:
parent
9fadf58e7b
commit
0fcf1517a5
2 changed files with 22 additions and 11 deletions
|
@ -1,4 +1,4 @@
|
||||||
set(TARGET_NAME model-networking)
|
set(TARGET_NAME model-networking)
|
||||||
setup_hifi_library()
|
setup_hifi_library()
|
||||||
link_hifi_libraries(shared networking graphics fbx ktx image)
|
link_hifi_libraries(shared networking graphics fbx ktx image gl)
|
||||||
include_hifi_library_headers(gpu)
|
include_hifi_library_headers(gpu)
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/random.hpp>
|
#include <glm/gtc/random.hpp>
|
||||||
|
|
||||||
|
#include <gl/GLHelpers.h>
|
||||||
#include <gpu/Batch.h>
|
#include <gpu/Batch.h>
|
||||||
|
|
||||||
#include <image/Image.h>
|
#include <image/Image.h>
|
||||||
|
@ -271,6 +272,20 @@ gpu::TexturePointer getFallbackTextureForType(image::TextureUsage::Type type) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gpu::BackendTarget getBackendTarget() {
|
||||||
|
#if defined(USE_GLES)
|
||||||
|
gpu::BackendTarget target = gpu::BackendTarget::GLES32;
|
||||||
|
#elif defined(Q_OS_MAC)
|
||||||
|
gpu::BackendTarget target = gpu::BackendTarget::GL41;
|
||||||
|
#else
|
||||||
|
gpu::BackendTarget target = gpu::BackendTarget::GL45;
|
||||||
|
if (gl::disableGl45()) {
|
||||||
|
target = gpu::BackendTarget::GL41;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns a texture version of an image file
|
/// Returns a texture version of an image file
|
||||||
gpu::TexturePointer TextureCache::getImageTexture(const QString& path, image::TextureUsage::Type type, QVariantMap options) {
|
gpu::TexturePointer TextureCache::getImageTexture(const QString& path, image::TextureUsage::Type type, QVariantMap options) {
|
||||||
QImage image = QImage(path);
|
QImage image = QImage(path);
|
||||||
|
@ -279,13 +294,14 @@ gpu::TexturePointer TextureCache::getImageTexture(const QString& path, image::Te
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
auto loader = image::TextureUsage::getTextureLoaderForType(type, options);
|
auto loader = image::TextureUsage::getTextureLoaderForType(type, options);
|
||||||
|
|
||||||
#ifdef USE_GLES
|
#ifdef USE_GLES
|
||||||
gpu::BackendTarget target = gpu::BackendTarget::GLES32;
|
constexpr bool shouldCompress = true;
|
||||||
bool shouldCompress = true;
|
|
||||||
#else
|
#else
|
||||||
gpu::BackendTarget target = gpu::BackendTarget::GL45;
|
constexpr bool shouldCompress = false;
|
||||||
bool shouldCompress = false;
|
|
||||||
#endif
|
#endif
|
||||||
|
auto target = getBackendTarget();
|
||||||
|
|
||||||
return gpu::TexturePointer(loader(std::move(image), path.toStdString(), shouldCompress, target, false));
|
return gpu::TexturePointer(loader(std::move(image), path.toStdString(), shouldCompress, target, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1170,15 +1186,10 @@ void ImageReader::read() {
|
||||||
|
|
||||||
#ifdef USE_GLES
|
#ifdef USE_GLES
|
||||||
constexpr bool shouldCompress = true;
|
constexpr bool shouldCompress = true;
|
||||||
gpu::BackendTarget target = gpu::BackendTarget::GLES32;
|
|
||||||
#else
|
#else
|
||||||
constexpr bool shouldCompress = false;
|
constexpr bool shouldCompress = false;
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
gpu::BackendTarget target = gpu::BackendTarget::GL41;
|
|
||||||
#else
|
|
||||||
gpu::BackendTarget target = gpu::BackendTarget::GL45;
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
auto target = getBackendTarget();
|
||||||
texture = image::processImage(std::move(buffer), _url.toString().toStdString(), _maxNumPixels, networkTexture->getTextureType(), shouldCompress, target);
|
texture = image::processImage(std::move(buffer), _url.toString().toStdString(), _maxNumPixels, networkTexture->getTextureType(), shouldCompress, target);
|
||||||
|
|
||||||
if (!texture) {
|
if (!texture) {
|
||||||
|
|
Loading…
Reference in a new issue