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
00023
00024
00026
00027 #ifndef GLC_TEXTURE_H_
00028 #define GLC_TEXTURE_H_
00029
00030 #include <QFile>
00031 #include <QtOpenGL>
00032
00033 #include "../glc_config.h"
00034
00037
00040
00041
00042
00043 class GLC_LIB_EXPORT GLC_Texture
00044 {
00046
00048
00049
00050 public:
00052 GLC_Texture(const QGLContext*);
00053
00055 GLC_Texture(const QGLContext*, const QString&);
00056
00058 GLC_Texture(const QGLContext*, const QFile&);
00059
00061 GLC_Texture(const QGLContext*, const QImage&, const QString& fileName= QString());
00062
00064 GLC_Texture(const GLC_Texture& TextureToCopy);
00065
00067 GLC_Texture& operator=(const GLC_Texture&);
00068
00070 virtual ~GLC_Texture();
00072
00074
00076
00077 public:
00079 inline QGLContext* context() const
00080 {return m_pQGLContext;}
00081
00083 inline QString fileName() const
00084 {return m_FileName;}
00085
00087 inline GLuint GL_ID() const
00088 {return m_GlTextureID;}
00089
00091 inline bool isLoaded() const
00092 {return (m_GlTextureID != 0);}
00093
00095 inline QSize size() const
00096 {return m_TextureSize;}
00097
00099 static QSize maxSize()
00100 {return m_MaxTextureSize;}
00101
00103 bool operator==(const GLC_Texture&) const;
00104
00106 inline bool hasAlphaChannel() const
00107 { return m_HasAlphaChannel;}
00108
00110 inline QImage imageOfTexture() const
00111 { return m_textureImage;}
00112
00113
00115
00117
00119
00120 public:
00121
00122 static void setMaxTextureSize(const QSize&);
00123
00125
00126
00128
00129 public:
00131 void glLoadTexture(void);
00133 void glcBindTexture(void);
00134
00135
00137
00139
00140 private:
00142 QImage loadFromFile(const QString& fileName);
00143
00145
00147
00149
00150 private:
00152 QGLContext *m_pQGLContext;
00153
00155 QString m_FileName;
00156
00158 GLuint m_GlTextureID;
00159
00161 QImage m_textureImage;
00162
00164 QSize m_TextureSize;
00165
00167 bool m_HasAlphaChannel;
00168
00170 static QSize m_MaxTextureSize;
00171 static const QSize m_MinTextureSize;
00172 };
00173
00175 QDataStream &operator<<(QDataStream &, const GLC_Texture &);
00176 QDataStream &operator>>(QDataStream &, GLC_Texture &);
00177
00178
00179 #endif //GLC_TEXTURE_H_