glc_texture.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  This file is part of the GLC-lib library.
00004  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
00005  Version 2.0.0 Beta 1, packaged on April 2010.
00006 
00007  http://glc-lib.sourceforge.net
00008 
00009  GLC-lib is free software; you can redistribute it and/or modify
00010  it under the terms of the GNU General Public License as published by
00011  the Free Software Foundation; either version 2 of the License, or
00012  (at your option) any later version.
00013 
00014  GLC-lib is distributed in the hope that it will be useful,
00015  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  GNU General Public License for more details.
00018 
00019  You should have received a copy of the GNU General Public License
00020  along with GLC-lib; if not, write to the Free Software
00021  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
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         // Set the maximum texture size
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 // Private members
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_

SourceForge.net Logo

©2005 Laurent Ribon