-istream &operator>>(istream &in, TextureFilter &tf)
-{
- string str;
- in>>str;
-
- if(str=="NEAREST")
- tf=NEAREST;
- else if(str=="LINEAR")
- tf=LINEAR;
- else if(str=="NEAREST_MIPMAP_NEAREST")
- tf=NEAREST_MIPMAP_NEAREST;
- else if(str=="NEAREST_MIPMAP_LINEAR")
- tf=NEAREST_MIPMAP_LINEAR;
- else if(str=="LINEAR_MIPMAP_NEAREST")
- tf=LINEAR_MIPMAP_NEAREST;
- else if(str=="LINEAR_MIPMAP_LINEAR")
- tf=LINEAR_MIPMAP_LINEAR;
+void operator>>(const LexicalConverter &c, TextureFilter &tf)
+{
+ if(c.get()=="NEAREST")
+ tf = NEAREST;
+ else if(c.get()=="LINEAR")
+ tf = LINEAR;
+ else if(c.get()=="NEAREST_MIPMAP_NEAREST")
+ tf = NEAREST_MIPMAP_NEAREST;
+ else if(c.get()=="NEAREST_MIPMAP_LINEAR")
+ tf = NEAREST_MIPMAP_LINEAR;
+ else if(c.get()=="LINEAR_MIPMAP_NEAREST")
+ tf = LINEAR_MIPMAP_NEAREST;
+ else if(c.get()=="LINEAR_MIPMAP_LINEAR")
+ tf = LINEAR_MIPMAP_LINEAR;
+ else
+ throw lexical_error(format("conversion of '%s' to TextureFilter", c.get()));
+}
+
+
+void operator>>(const LexicalConverter &c, TextureWrap &tw)
+{
+ if(c.get()=="REPEAT")
+ tw = REPEAT;
+ else if(c.get()=="CLAMP_TO_EDGE")
+ tw = CLAMP_TO_EDGE;
+ else if(c.get()=="MIRRORED_REPEAT")
+ tw = MIRRORED_REPEAT;
+ else
+ throw lexical_error(format("conversion of '%s' to TextureWrap", c.get()));
+}
+
+
+int Texture::swizzle_orders[] =
+{
+ GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA,
+ GL_RED, GL_RED, GL_RED, GL_ONE,
+ GL_RED, GL_RED, GL_RED, GL_GREEN
+};
+
+Texture::Texture(GLenum t, ResourceManager *m):
+ id(0),
+ target(t),
+ ifmt(RGB),
+ min_filter(NEAREST_MIPMAP_LINEAR),
+ mag_filter(LINEAR),
+ max_anisotropy(1.0f),
+ wrap_s(REPEAT),
+ wrap_t(REPEAT),
+ wrap_r(REPEAT),
+ gen_mipmap(false),
+ compare(false),
+ cmp_func(LEQUAL),
+ dirty_params(0)
+{
+ if(m)
+ set_manager(m);
+ else if(ARB_direct_state_access)
+ glCreateTextures(target, 1, &id);