/* QGL CubeTexture Ivan Pelipenko peri4ko@yandex.ru This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ #ifndef GLCUBEMAP_H #define GLCUBEMAP_H #include "glshaders_types.h" #include "chunkstream.h" QVector loadFileHDR(const QString & path, QSize * size = 0); class CubeTexture { public: CubeTexture(QOpenGLExtraFunctions * f_, int _size, const GLenum & _format = GL_RGB16F); bool init(); void destroy(); void bind(int channel = 0); void release(); void resize(int _size) {size = _size; changed_ = true;} void loadHDR(const QVector & data, QSize sz); void setFileHDR(const QString & path); QString fileHDR() const {return hdr_path;} //void loadFromDirectory(const QString & dir); //void loadFront(const QString & path) {bind(); pathes[0] = path; createGLTexture(id_, rotateQImageLeft(QImage(path)).scaled(size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), format_, GL_TEXTURE_CUBE_MAP_POSITIVE_X);} //void loadBack(const QString & path) {bind(); pathes[1] = path; createGLTexture(id_, rotateQImageRight(QImage(path)).scaled(size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), format_, GL_TEXTURE_CUBE_MAP_NEGATIVE_X);} //void loadLeft(const QString & path) {bind(); pathes[2] = path; createGLTexture(id_, QImage(path).scaled(size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), format_, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y);} //void loadRight(const QString & path) {bind(); pathes[3] = path; createGLTexture(id_, rotateQImage180(QImage(path)).scaled(size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), format_, GL_TEXTURE_CUBE_MAP_POSITIVE_Y);} //void loadTop(const QString & path) {bind(); pathes[4] = path; createGLTexture(id_, rotateQImageLeft(QImage(path)).scaled(size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), format_, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z);} //void loadBottom(const QString & path) {bind(); pathes[5] = path; createGLTexture(id_, rotateQImageLeft(QImage(path)).scaled(size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), format_, GL_TEXTURE_CUBE_MAP_POSITIVE_Z);} //void load(); //bool isEmpty() const {foreach (const QString & i, pathes) if (!i.isEmpty()) return false; return true;} GLenum format() const {return format_;} void setFormat(GLenum f) {format_ = f; changed_ = true;} GLuint id() const {return id_;} bool isInit() const {return id_ != 0;} //const QString & path(int side) const {return pathes[side];} //void setPath(int side, const QString & p) {pathes[side] = p;} //void loadPathesFromDirectory(const QString & dir); void load(); private: QOpenGLExtraFunctions * f; bool changed_; int size; GLenum format_; GLuint id_; QString hdr_path; //QVector pathes; }; #endif // GLCUBEMAP_H