31 #ifndef _GG_Texture_h_
32 #define _GG_Texture_h_
37 #include <boost/serialization/access.hpp>
38 #include <boost/serialization/binary_object.hpp>
74 std::string Filename()
const;
77 GLenum MinFilter()
const;
78 GLenum MagFilter()
const;
79 unsigned int BytesPP()
const;
82 bool MipMapped()
const;
83 GLuint OpenGLId()
const;
84 const GLfloat* DefaultTexCoords()
const;
85 X DefaultWidth()
const;
86 Y DefaultHeight()
const;
90 void OrthoBlit(
const Pt& pt1,
const Pt& pt2,
const GLfloat* tex_coords = 0)
const;
94 void OrthoBlit(
const Pt& pt)
const;
102 void Load(
const std::string& filename,
bool mipmap =
false);
108 void Init(
X width,
Y height,
const unsigned char* image, GLenum format, GLenum type,
109 unsigned bytes_per_pixel,
bool mipmap =
false);
115 void Init(
X x,
Y y,
X width,
Y height,
X image_width,
116 const unsigned char* image, GLenum format, GLenum type,
117 unsigned int bytes_per_pixel,
bool mipmap =
false);
119 void SetWrap(GLenum s, GLenum t);
120 void SetFilters(GLenum min, GLenum mag);
141 void InitFromRawData(
X width,
Y height,
const unsigned char* image, GLenum format, GLenum type,
142 unsigned int bytes_per_pixel,
bool mipmap);
143 unsigned char* GetRawBytes();
145 std::string m_filename;
147 unsigned int m_bytes_pp;
151 GLenum m_wrap_s, m_wrap_t;
152 GLenum m_min_filter, m_mag_filter;
160 GLfloat m_tex_coords[4];
164 friend class boost::serialization::access;
165 template <
class Archive>
166 void serialize(Archive& ar,
const unsigned int version);
181 SubTexture(
const boost::shared_ptr<const Texture>& texture,
X x1,
Y y1,
X x2,
Y y2);
190 const GLfloat* TexCoords()
const;
193 const Texture* GetTexture()
const;
197 void OrthoBlit(
const Pt& pt1,
const Pt& pt2)
const;
201 void OrthoBlit(
const Pt& pt)
const;
218 boost::shared_ptr<const Texture> m_texture;
221 GLfloat m_tex_coords[4];
240 boost::shared_ptr<Texture> StoreTexture(
Texture* texture,
const std::string& texture_name);
246 boost::shared_ptr<Texture> StoreTexture(
const boost::shared_ptr<Texture>& texture,
const std::string& texture_name);
251 boost::shared_ptr<Texture> GetTexture(
const std::string& name,
bool mipmap =
false);
256 void FreeTexture(
const std::string& name);
261 boost::shared_ptr<Texture> LoadTexture(
const std::string& filename,
bool mipmap);
263 static bool s_created;
264 static bool s_il_initialized;
265 std::map<std::string, boost::shared_ptr<Texture> > m_textures;