glc_texture.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00024
00025 #ifndef GLC_TEXTURE_H_
00026 #define GLC_TEXTURE_H_
00027
00028 #include <QFile>
00029 #include <QtOpenGL>
00030
00031 #include "../glc_config.h"
00032
00035
00038
00039
00040
00041 class GLC_LIB_EXPORT GLC_Texture
00042 {
00044
00046
00047
00048 public:
00050 GLC_Texture();
00051
00053 GLC_Texture(const QString&);
00054
00056 GLC_Texture(const QFile&);
00057
00059 GLC_Texture(const QImage&, const QString& fileName= QString());
00060
00062 GLC_Texture(const GLC_Texture& TextureToCopy);
00063
00065 GLC_Texture& operator=(const GLC_Texture&);
00066
00068 virtual ~GLC_Texture();
00070
00072
00074
00075 public:
00077 inline QGLContext* context() const
00078 {return m_pQGLContext;}
00079
00081 inline QString fileName() const
00082 {return m_FileName;}
00083
00085 inline GLuint GL_ID() const
00086 {return m_GlTextureID;}
00087
00089 inline bool isLoaded() const
00090 {return (m_GlTextureID != 0);}
00091
00093 inline QSize size() const
00094 {return m_TextureSize;}
00095
00097 static QSize maxSize()
00098 {return m_MaxTextureSize;}
00099
00101 bool operator==(const GLC_Texture&) const;
00102
00104 inline bool hasAlphaChannel() const
00105 { return m_HasAlphaChannel;}
00106
00108 inline QImage imageOfTexture() const
00109 { return m_textureImage;}
00110
00111
00113
00115
00117
00118 public:
00119
00120 static void setMaxTextureSize(const QSize&);
00121
00123
00124
00126
00127 public:
00129 void glLoadTexture(QGLContext* pContext= NULL);
00131 void glcBindTexture(void);
00132
00133
00135
00137
00138 private:
00140 QImage loadFromFile(const QString& fileName);
00141
00143 void removeThisOpenGLTextureId();
00144
00146 void addThisOpenGLTextureId();
00147
00149
00151
00153
00154 private:
00156 QGLContext *m_pQGLContext;
00157
00159 QString m_FileName;
00160
00162 GLuint m_GlTextureID;
00163
00165 QImage m_textureImage;
00166
00168 QSize m_TextureSize;
00169
00171 bool m_HasAlphaChannel;
00172
00174 static QSize m_MaxTextureSize;
00175 static const QSize m_MinTextureSize;
00176
00178 static QHash<GLuint, int> m_TextureIdUsage;
00179 };
00180
00182 QDataStream &operator<<(QDataStream &, const GLC_Texture &);
00183 QDataStream &operator>>(QDataStream &, GLC_Texture &);
00184
00185
00186 #endif //GLC_TEXTURE_H_