Home · All Namespaces · All Classes · Functions · Coding Style · Plugins · File Structure

core/StelTexture.hpp

00001 /*
00002  * Stellarium
00003  * Copyright (C) 2006 Fabien Chereau
00004  * 
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  * 
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018  */
00019 
00020 #ifndef _STELTEXTURE_HPP_
00021 #define _STELTEXTURE_HPP_
00022 
00023 #include "GLee.h"
00024 #include "fixx11h.h"
00025 #include "VecMath.hpp"
00026 #include "StelTextureTypes.hpp"
00027 
00028 #include <QObject>
00029 #include <QImage>
00030 
00031 class QMutex;
00032 class QSemaphore;
00033 class QFile;
00034 
00038 class StelTexture : public QObject
00039 {
00040     Q_OBJECT
00041     
00042     friend class StelTextureMgr;
00043     friend class ImageLoadThread;
00044 
00045 public:
00047     virtual ~StelTexture();
00048     
00052     bool bind();
00053     
00055     bool canBind() const {return id!=0;}
00056     
00060     bool getAverageLuminance(float& lum);
00061 
00063     bool getDimensions(int &width, int &height);
00064 
00066     const Vec2d* getCoordinates() const {return texCoordinates;}
00067 
00070     const QString& getErrorMessage() const {return errorMessage;}
00071     
00074     const QString& getFullPath() const {return fullPath;}
00075     
00077     bool isLoading() const {return isLoadingImage && !canBind();}
00078     
00079 signals:
00084     void loadingProcessFinished(bool error);
00085     
00086 private slots:
00088     void downloadFinished();
00089     
00091     void fileLoadFinished();
00092     
00093 private:
00095     StelTexture();
00096     
00100     bool glLoad();
00101     
00105     bool imageLoad();
00106     
00109     void reportError(const QString& errorMessage);
00110     
00112     StelTextureTypes::DynamicRangeMode dynamicRangeMode;
00113     
00115     class QNetworkReply* httpReply;
00116     
00118     class ImageLoadThread* loadThread;
00119             
00121     bool downloaded;
00123     bool isLoadingImage;
00124     
00126     QString fullPath;
00127     
00129     QByteArray downloadedData;
00130     QImage qImage;
00131     
00133     QString fileExtension;
00134     
00136     bool errorOccured;
00137     
00139     QString errorMessage;
00140     
00142     GLuint id;
00143     bool mipmapsMode;
00144     GLint wrapMode;
00145     GLint minFilter;
00146     GLint magFilter;
00147             
00149     // Attributes protected by the Mutex
00151     QMutex* mutex;
00152 
00154     float avgLuminance;
00155     
00156     GLsizei width;  
00157     GLsizei height; 
00158     GLenum format;
00159     GLint internalFormat;
00160     GLubyte* texels;
00161     GLenum type;
00162     
00164     Vec2d texCoordinates[4];
00165     
00167     static QSemaphore* maxLoadThreadSemaphore;
00168 };
00169 
00170 
00171 #endif // _STELTEXTURE_HPP_

Generated on Mon Mar 9 16:16:16 2009 for Stellarium by  doxygen 1.5.5