refactor texture loading, maps invert channels works
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#ifndef GLTEXTUREMANAGER_H
|
||||
#define GLTEXTUREMANAGER_H
|
||||
|
||||
#include "glmaterial.h"
|
||||
#include "qglengine_core_export.h"
|
||||
|
||||
#include <QDir>
|
||||
@@ -33,32 +34,42 @@ public:
|
||||
TextureManager(QOpenGLExtraFunctions * f_): f(f_) {}
|
||||
virtual ~TextureManager() {}
|
||||
|
||||
// GLuint loadTexture(const QString & path, bool is_normal = false, MapBakeOptions opts = {});
|
||||
// GLuint loadTexture(const QImage & image, bool ownership = true, bool is_normal = false, MapBakeOptions opts = {});
|
||||
QImage loadTextureImage(const QString & path, bool is_normal = false, MapBakeOptions opts = {}, uint * result_hash = nullptr);
|
||||
// void reloadTexture(GLuint tid, const QString & path);
|
||||
// void reloadTexture(GLuint tid, const QImage & image);
|
||||
int textureID(const QString & path, bool is_normal = false, MapBakeOptions opts = {});
|
||||
QImage textureImage(const QString & path, bool is_normal = false, MapBakeOptions opts = {});
|
||||
QImage textureImage(uint hash) const { return cache_image.value(hash); }
|
||||
int textureLayer(uint hash) const { return array_layers.value(hash); }
|
||||
// void addTexture(const QString & path) { tex_pathes << path; }
|
||||
// bool loadTextures();
|
||||
// void deleteTextures();
|
||||
// void deleteTexture(const QString & name);
|
||||
int texturesCount() const { return cache_image.size(); }
|
||||
uint texturesHash() const { return qHash(cache_image.keys()); }
|
||||
void clearImageCache();
|
||||
|
||||
void loadToTexture2DArray(Texture2DArray * array, QSize map_size);
|
||||
|
||||
static void addSearchPath(const QString & path);
|
||||
static void clearSearchPathes() { search_pathes.clear(); }
|
||||
static QStringList searchPathes() { return search_pathes; }
|
||||
static QString findFile(const QString & path);
|
||||
GLuint loadTexture(const QString & path, bool ownership = true, bool bump = false);
|
||||
GLuint loadTexture(const QImage & image, bool ownership = true, bool bump = false);
|
||||
QImage loadTextureImage(const QString & path, bool bump = false);
|
||||
void reloadTexture(GLuint tid, const QString & path);
|
||||
void reloadTexture(GLuint tid, const QImage & image);
|
||||
int textureID(const QString & path, bool bump = false) { return tex_ids[bump ? 1 : 0][path]; }
|
||||
QImage textureImage(const QString & path, bool bump = false) { return tex_im[bump ? 1 : 0][path]; }
|
||||
void addTexture(const QString & path) { tex_pathes << path; }
|
||||
bool loadTextures();
|
||||
void deleteTextures();
|
||||
void deleteTexture(const QString & name);
|
||||
void clearImageCache();
|
||||
|
||||
protected:
|
||||
static void convertToNormal(QImage & im);
|
||||
static void applyBakeOption(QImage & im, MapBakeOptions opts);
|
||||
static uint mapHash(const QString & path, bool is_normal, MapBakeOptions opts);
|
||||
|
||||
static QStringList search_pathes;
|
||||
|
||||
QMap<QString, GLuint> tex_ids[2];
|
||||
QMap<QString, QImage> tex_im[2];
|
||||
QStringList tex_pathes;
|
||||
QOpenGLExtraFunctions * f;
|
||||
QMap<uint, GLuint> cache_loaded;
|
||||
QMap<uint, QImage> cache_image;
|
||||
QMap<uint, int> array_layers;
|
||||
QStringList tex_pathes;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user