mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 02:36:54 +02:00
Fixes to load cubemap
This commit is contained in:
parent
3d186efbac
commit
a2c2e7d9ff
7 changed files with 71 additions and 7 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -77,3 +77,4 @@ TAGS
|
||||||
# ignore node files for the console
|
# ignore node files for the console
|
||||||
node_modules
|
node_modules
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
|
*___jb_old___
|
|
@ -212,6 +212,8 @@
|
||||||
#if defined(Q_OS_ANDROID)
|
#if defined(Q_OS_ANDROID)
|
||||||
#include <QtAndroidExtras/QAndroidJniObject>
|
#include <QtAndroidExtras/QAndroidJniObject>
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
|
#include <android/asset_manager.h>
|
||||||
|
#include <android/asset_manager_jni.h>
|
||||||
#endif
|
#endif
|
||||||
// On Windows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU
|
// On Windows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU
|
||||||
// FIXME seems to be broken.
|
// FIXME seems to be broken.
|
||||||
|
@ -238,6 +240,7 @@ extern "C" {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
JNIEXPORT void Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeOnCreate(JNIEnv* env, jobject obj, jobject instance, jobject asset_mgr) {
|
JNIEXPORT void Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeOnCreate(JNIEnv* env, jobject obj, jobject instance, jobject asset_mgr) {
|
||||||
|
storage::FileStorage::setAssetManager(AAssetManager_fromJava(env, asset_mgr));
|
||||||
qDebug() << "nativeOnCreate On thread " << QThread::currentThreadId();
|
qDebug() << "nativeOnCreate On thread " << QThread::currentThreadId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,7 +335,11 @@ static QTimer identityPacketTimer;
|
||||||
static QTimer pingTimer;
|
static QTimer pingTimer;
|
||||||
|
|
||||||
static const QString DISABLE_WATCHDOG_FLAG("HIFI_DISABLE_WATCHDOG");
|
static const QString DISABLE_WATCHDOG_FLAG("HIFI_DISABLE_WATCHDOG");
|
||||||
|
#if defined(Q_OS_ANDROID)
|
||||||
|
static bool DISABLE_WATCHDOG = true;
|
||||||
|
#else
|
||||||
static bool DISABLE_WATCHDOG = QProcessEnvironment::systemEnvironment().contains(DISABLE_WATCHDOG_FLAG);
|
static bool DISABLE_WATCHDOG = QProcessEnvironment::systemEnvironment().contains(DISABLE_WATCHDOG_FLAG);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static const int MAX_CONCURRENT_RESOURCE_DOWNLOADS = 16;
|
static const int MAX_CONCURRENT_RESOURCE_DOWNLOADS = 16;
|
||||||
|
@ -1777,7 +1784,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
static int lastCountOfNearbyAvatars = -1;
|
static int lastCountOfNearbyAvatars = -1;
|
||||||
QTimer* checkNearbyAvatarsTimer = new QTimer(this);
|
QTimer* checkNearbyAvatarsTimer = new QTimer(this);
|
||||||
checkNearbyAvatarsTimer->setInterval(CHECK_NEARBY_AVATARS_INTERVAL_MS); // 10 seconds, Qt::CoarseTimer ok
|
checkNearbyAvatarsTimer->setInterval(CHECK_NEARBY_AVATARS_INTERVAL_MS); // 10 seconds, Qt::CoarseTimer ok
|
||||||
connect(checkNearbyAvatarsTimer, &QTimer::timeout, this, [this]() {
|
connect(checkNearbyAvatarsTimer, &QTimer::timeout, this, []() {
|
||||||
auto avatarManager = DependencyManager::get<AvatarManager>();
|
auto avatarManager = DependencyManager::get<AvatarManager>();
|
||||||
int nearbyAvatars = avatarManager->numberOfAvatarsInRange(avatarManager->getMyAvatar()->getWorldPosition(),
|
int nearbyAvatars = avatarManager->numberOfAvatarsInRange(avatarManager->getMyAvatar()->getWorldPosition(),
|
||||||
NEARBY_AVATAR_RADIUS_METERS) - 1;
|
NEARBY_AVATAR_RADIUS_METERS) - 1;
|
||||||
|
|
|
@ -499,9 +499,13 @@ TexturePointer Texture::build(const ktx::KTXDescriptor& descriptor) {
|
||||||
GPUKTXPayload gpuktxKeyValue;
|
GPUKTXPayload gpuktxKeyValue;
|
||||||
if (!GPUKTXPayload::findInKeyValues(descriptor.keyValues, gpuktxKeyValue)) {
|
if (!GPUKTXPayload::findInKeyValues(descriptor.keyValues, gpuktxKeyValue)) {
|
||||||
qCWarning(gpulogging) << "Could not find GPUKTX key values.";
|
qCWarning(gpulogging) << "Could not find GPUKTX key values.";
|
||||||
return TexturePointer();
|
// FIXME use sensible defaults based on the texture type and format
|
||||||
|
gpuktxKeyValue._usageType = TextureUsageType::RESOURCE;
|
||||||
|
gpuktxKeyValue._usage = Texture::Usage::Builder().withColor().withAlpha().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
auto texture = create(gpuktxKeyValue._usageType,
|
auto texture = create(gpuktxKeyValue._usageType,
|
||||||
type,
|
type,
|
||||||
texelFormat,
|
texelFormat,
|
||||||
|
|
|
@ -7,5 +7,9 @@ if (WIN32)
|
||||||
target_link_libraries(${TARGET_NAME} Wbemuuid.lib)
|
target_link_libraries(${TARGET_NAME} Wbemuuid.lib)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (ANDROID)
|
||||||
|
target_link_libraries(${TARGET_NAME} android)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_zlib()
|
target_zlib()
|
||||||
target_nsight()
|
target_nsight()
|
|
@ -33,7 +33,7 @@ const QString& PathUtils::resourcesPath() {
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
static const QString staticResourcePath = QCoreApplication::applicationDirPath() + "/../Resources/";
|
static const QString staticResourcePath = QCoreApplication::applicationDirPath() + "/../Resources/";
|
||||||
#elif defined (ANDROID)
|
#elif defined (ANDROID)
|
||||||
static const QString staticResourcePath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/resources/";
|
static const QString staticResourcePath = "assets:/resources/";
|
||||||
#else
|
#else
|
||||||
static const QString staticResourcePath = QCoreApplication::applicationDirPath() + "/resources/";
|
static const QString staticResourcePath = QCoreApplication::applicationDirPath() + "/resources/";
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -47,6 +47,13 @@ MemoryStorage::MemoryStorage(size_t size, const uint8_t* data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(Q_OS_ANDROID)
|
||||||
|
static AAssetManager* g_assetManager = nullptr;
|
||||||
|
void FileStorage::setAssetManager(AAssetManager* assetManager) {
|
||||||
|
::g_assetManager = assetManager;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
StoragePointer FileStorage::create(const QString& filename, size_t size, const uint8_t* data) {
|
StoragePointer FileStorage::create(const QString& filename, size_t size, const uint8_t* data) {
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
if (!file.open(QFile::ReadWrite | QIODevice::Truncate)) {
|
if (!file.open(QFile::ReadWrite | QIODevice::Truncate)) {
|
||||||
|
@ -69,7 +76,27 @@ StoragePointer FileStorage::create(const QString& filename, size_t size, const u
|
||||||
return std::make_shared<FileStorage>(filename);
|
return std::make_shared<FileStorage>(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FileStorage::FileStorage(const QString& filename) : _file(filename) {
|
FileStorage::FileStorage(const QString& filename) : _file(filename) {
|
||||||
|
#if defined(Q_OS_ANDROID)
|
||||||
|
static const QString ASSETS_PREFIX("assets:/");
|
||||||
|
bool isAsset = filename.startsWith(ASSETS_PREFIX);
|
||||||
|
if (isAsset) {
|
||||||
|
_hasWriteAccess = false;
|
||||||
|
std::string strFilename = filename.mid(ASSETS_PREFIX.size()).toStdString();
|
||||||
|
// Load shader from compressed asset
|
||||||
|
_asset = AAssetManager_open(g_assetManager, strFilename.c_str(), AASSET_MODE_BUFFER);
|
||||||
|
if (!_asset) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_size = AAsset_getLength64(_asset);
|
||||||
|
_mapped = (uint8_t*)AAsset_getBuffer(_asset);
|
||||||
|
if (_mapped) {
|
||||||
|
_valid = true;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
bool opened = _file.open(QFile::ReadWrite);
|
bool opened = _file.open(QFile::ReadWrite);
|
||||||
if (opened) {
|
if (opened) {
|
||||||
_hasWriteAccess = true;
|
_hasWriteAccess = true;
|
||||||
|
@ -79,6 +106,7 @@ FileStorage::FileStorage(const QString& filename) : _file(filename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opened) {
|
if (opened) {
|
||||||
|
_size = _file.size();
|
||||||
_mapped = _file.map(0, _file.size());
|
_mapped = _file.map(0, _file.size());
|
||||||
if (_mapped) {
|
if (_mapped) {
|
||||||
_valid = true;
|
_valid = true;
|
||||||
|
@ -91,6 +119,14 @@ FileStorage::FileStorage(const QString& filename) : _file(filename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
FileStorage::~FileStorage() {
|
FileStorage::~FileStorage() {
|
||||||
|
#if defined(Q_OS_ANDROID)
|
||||||
|
if (_asset) {
|
||||||
|
_mapped = nullptr;
|
||||||
|
AAsset_close(_asset);
|
||||||
|
_asset = nullptr;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (_mapped) {
|
if (_mapped) {
|
||||||
_file.unmap(_mapped);
|
_file.unmap(_mapped);
|
||||||
_mapped = nullptr;
|
_mapped = nullptr;
|
||||||
|
|
|
@ -13,8 +13,14 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <QFile>
|
|
||||||
#include <QString>
|
#include <QtCore/qtglobal>
|
||||||
|
#include <QtCore/QFile>
|
||||||
|
#include <QtCore/QString>
|
||||||
|
|
||||||
|
#if defined(Q_OS_ANDROID)
|
||||||
|
#include <android/asset_manager.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace storage {
|
namespace storage {
|
||||||
class Storage;
|
class Storage;
|
||||||
|
@ -52,6 +58,9 @@ namespace storage {
|
||||||
|
|
||||||
class FileStorage : public Storage {
|
class FileStorage : public Storage {
|
||||||
public:
|
public:
|
||||||
|
#if defined(Q_OS_ANDROID)
|
||||||
|
static void setAssetManager(AAssetManager* assetManager);
|
||||||
|
#endif
|
||||||
static StoragePointer create(const QString& filename, size_t size, const uint8_t* data);
|
static StoragePointer create(const QString& filename, size_t size, const uint8_t* data);
|
||||||
FileStorage(const QString& filename);
|
FileStorage(const QString& filename);
|
||||||
~FileStorage();
|
~FileStorage();
|
||||||
|
@ -61,10 +70,13 @@ namespace storage {
|
||||||
|
|
||||||
const uint8_t* data() const override { return _mapped; }
|
const uint8_t* data() const override { return _mapped; }
|
||||||
uint8_t* mutableData() override { return _hasWriteAccess ? _mapped : nullptr; }
|
uint8_t* mutableData() override { return _hasWriteAccess ? _mapped : nullptr; }
|
||||||
size_t size() const override { return _file.size(); }
|
size_t size() const override { return _size; }
|
||||||
operator bool() const override { return _valid; }
|
operator bool() const override { return _valid; }
|
||||||
private:
|
private:
|
||||||
|
#if defined(Q_OS_ANDROID)
|
||||||
|
AAsset* _asset { nullptr };
|
||||||
|
#endif
|
||||||
|
size_t _size { 0 };
|
||||||
bool _valid { false };
|
bool _valid { false };
|
||||||
bool _hasWriteAccess { false };
|
bool _hasWriteAccess { false };
|
||||||
QFile _file;
|
QFile _file;
|
||||||
|
|
Loading…
Reference in a new issue