git-svn-id: svn://db.shs.com.ru/libs@1 a8b55f48-bf90-11e4-a774-851b48703e85
55 lines
1.9 KiB
C++
55 lines
1.9 KiB
C++
/*
|
|
QGLView
|
|
Copyright (C) 2012 Ivan Pelipenko peri4ko@gmail.com
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "gltexture_manager.h"
|
|
|
|
|
|
bool GLTextureManager::loadTextures() {
|
|
//glGenTextures();
|
|
QFileInfoList fil;
|
|
Animation anim;
|
|
for (int i = 0; i < anim_pathes.size(); ++i) {
|
|
anim.path = anim_pathes[i].second;
|
|
anim.bitmaps.clear();
|
|
fil = QDir(anim_pathes[i].first).entryInfoList(QDir::Files, QDir::Name);
|
|
foreach (const QFileInfo & fi, fil) {
|
|
if (fi.baseName().indexOf(anim_pathes[i].second) < 0) continue;
|
|
anim.bitmaps << loadTexture(fi.filePath(), false);
|
|
}
|
|
qDebug() << "[TextureManager] Loaded" << anim.bitmaps.size() << "frames";
|
|
anim_ids << QPair<QString, Animation>(anim_pathes[i].second, anim);
|
|
}
|
|
anim_pathes.clear();
|
|
foreach (const QString & i, tex_pathes)
|
|
loadTexture(i, true);
|
|
tex_pathes.clear();
|
|
return true;
|
|
}
|
|
|
|
|
|
void GLTextureManager::deleteTextures() {
|
|
QList<GLuint> texs = tex_ids.values();
|
|
qDebug() << "[TextureManager] Delete" << texs.size() << "textures";
|
|
if (!texs.isEmpty()) glDeleteTextures(texs.size(), &texs[0]);
|
|
tex_ids.clear();
|
|
qDebug() << "[TextureManager] Delete" << anim_ids.size() << "animations";
|
|
for (int i = 0; i < anim_ids.size(); ++i)
|
|
glDeleteTextures(anim_ids[i].second.bitmaps.size(), anim_ids[i].second.bitmaps.data());
|
|
anim_ids.clear();
|
|
}
|