00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
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_