git-svn-id: svn://db.shs.com.ru/libs@375 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2018-04-19 20:10:15 +00:00
parent 79d1654f07
commit 11302ac363
3 changed files with 35 additions and 2 deletions

View File

@@ -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) {