GLC_lib  2.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
glc_texture.h
Go to the documentation of this file.
1 /****************************************************************************
2 
3  This file is part of the GLC-lib library.
4  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
5  http://glc-lib.sourceforge.net
6 
7  GLC-lib is free software; you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version.
11 
12  GLC-lib is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with GLC-lib; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21 *****************************************************************************/
22 
24 
25 #ifndef GLC_TEXTURE_H_
26 #define GLC_TEXTURE_H_
27 
28 #include <QFile>
29 #include <QtOpenGL>
30 
31 #include "../glc_config.h"
32 
35 
38 
39 
40 
42 {
44 
46 
47 
48 public:
50  GLC_Texture();
51 
53  GLC_Texture(const QString&);
54 
56  GLC_Texture(const QFile&);
57 
59  GLC_Texture(const QImage&, const QString& fileName= QString());
60 
62  GLC_Texture(const GLC_Texture& TextureToCopy);
63 
65  GLC_Texture& operator=(const GLC_Texture&);
66 
68  virtual ~GLC_Texture();
70 
72 
74 
75 public:
77  inline QGLContext* context() const
78  {return m_pQGLContext;}
79 
81  inline QString fileName() const
82  {return m_FileName;}
83 
85  inline GLuint GL_ID() const
86  {return m_GlTextureID;}
87 
89  inline bool isLoaded() const
90  {return (m_GlTextureID != 0);}
91 
93  inline QSize size() const
94  {return m_TextureSize;}
95 
97  static QSize maxSize()
98  {return m_MaxTextureSize;}
99 
101  bool operator==(const GLC_Texture&) const;
102 
104  inline bool hasAlphaChannel() const
105  { return m_HasAlphaChannel;}
106 
108  inline QImage imageOfTexture() const
109  { return m_textureImage;}
110 
111 
113 
115 
117 
118 public:
119  // Set the maximum texture size
120  static void setMaxTextureSize(const QSize&);
121 
123 
124 
126 
127 public:
129  void glLoadTexture(QGLContext* pContext= NULL);
131  void glcBindTexture(void);
132 
133 
135 
137 
138 private:
140  QImage loadFromFile(const QString& fileName);
141 
143  void removeThisOpenGLTextureId();
144 
146  void addThisOpenGLTextureId();
147 
149 
151 // Private members
153 
154 private:
156  QGLContext *m_pQGLContext;
157 
159  QString m_FileName;
160 
163 
166 
169 
172 
174  static QSize m_MaxTextureSize;
175  static const QSize m_MinTextureSize;
176 
178  static QHash<GLuint, int> m_TextureIdUsage;
179 };
180 
182 QDataStream &operator<<(QDataStream &, const GLC_Texture &);
183 QDataStream &operator>>(QDataStream &, GLC_Texture &);
184 
185 
186 #endif //GLC_TEXTURE_H_

©2005-2013 Laurent Ribon