git-svn-id: svn://db.shs.com.ru/libs@375 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -82,9 +82,15 @@ void GLCubeTexture::loadPathesFromDirectory(const QString & dir) {
|
||||
|
||||
|
||||
|
||||
QString GLTextureManagerBase::findFile(const QString & path) {
|
||||
if (!currentGLTextureManager) return QString();
|
||||
return ::findFile(path, currentGLTextureManager->search_pathes);
|
||||
}
|
||||
|
||||
|
||||
GLuint GLTextureManagerBase::loadTexture(const QString & path, bool ownership, bool bump) {
|
||||
if (!currentGLTextureManager) return 0;
|
||||
QString p = findFile(path, search_pathes);
|
||||
QString p = findFile(path);
|
||||
if (p.isEmpty()) return 0;
|
||||
int tid = ((GLTextureManagerBase*)currentGLTextureManager)->textureID(p, bump);
|
||||
if (tid > 0) {
|
||||
@@ -124,6 +130,30 @@ GLuint GLTextureManagerBase::loadTexture(const QImage & im, bool ownership, bool
|
||||
return tid;
|
||||
}
|
||||
|
||||
|
||||
void GLTextureManagerBase::reloadTexture(GLuint tid, const QString & path) {
|
||||
if (!currentGLTextureManager) return;
|
||||
QString p = findFile(path);
|
||||
if (p.isEmpty()) return;
|
||||
QImage image(p);
|
||||
createGLTexture(tid, image);
|
||||
if (tid == 0) {
|
||||
qDebug() << "[TextureManager] Can`t load" << p;
|
||||
return;
|
||||
}
|
||||
qDebug() << "[TextureManager] Reloaded" << p << "as" << tid;
|
||||
}
|
||||
|
||||
|
||||
void GLTextureManagerBase::reloadTexture(GLuint tid, const QImage & im) {
|
||||
if (!currentGLTextureManager) return;
|
||||
if (im.isNull()) return;
|
||||
QImage image(im);
|
||||
createGLTexture(tid, image);
|
||||
qDebug() << "[TextureManager] Reloaded" << tid;
|
||||
}
|
||||
|
||||
|
||||
Vector3d colorVector(QRgb c) {return Vector3d(((uchar*)(&c))[0] / 255., ((uchar*)(&c))[1] / 255., ((uchar*)(&c))[2] / 255.);}
|
||||
|
||||
void GLTextureManagerBase::convertToNormal(QImage & im) {
|
||||
|
||||
@@ -78,8 +78,11 @@ class GLTextureManagerBase {
|
||||
public:
|
||||
static void addSearchPath(const QString & path) {search_pathes << path;}
|
||||
static QStringList searchPathes() {return search_pathes;}
|
||||
static QString findFile(const QString & path);
|
||||
static GLuint loadTexture(const QString & path, bool ownership = true, bool bump = false);
|
||||
static GLuint loadTexture(const QImage & image, bool ownership = true, bool bump = false);
|
||||
static void reloadTexture(GLuint tid, const QString & path);
|
||||
static void reloadTexture(GLuint tid, const QImage & image);
|
||||
int textureID(const QString & path, bool bump = false) {return tex_ids[bump ? 1 : 0][path];}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -141,8 +141,8 @@ void createGLTexture(GLuint & tex, int width, int height, const GLenum & format,
|
||||
void createGLTexture(GLuint & tex, const QImage & image, const GLenum & format, const GLenum & target) {
|
||||
if (tex == 0) {
|
||||
glGenTextures(1, &tex);
|
||||
glBindTexture(target, tex);
|
||||
}
|
||||
glBindTexture(target, tex);
|
||||
QImage im = image.mirrored(false, true);///__GLWidget__::convertToGLFormat(image);
|
||||
//const QImage & cim(im);
|
||||
//glClearError();
|
||||
|
||||
Reference in New Issue
Block a user