+PixelFormat Texture::get_upload_format(PixelFormat fmt) const
+{
+ if(fmt==LUMINANCE || fmt==LUMINANCE_ALPHA)
+ return get_base_pixelformat(ifmt);
+ else
+ return fmt;
+}
+
+void Texture::update_parameter(int mask) const
+{
+ if(!ARB_direct_state_access && TexUnit::current().get_texture()!=this)
+ {
+ TexUnit *unit = TexUnit::find_unit(this);
+ if(!unit)
+ {
+ dirty_params |= mask;
+ return;
+ }
+
+ unit->bind();
+ }
+
+ if(mask&MIN_FILTER)
+ set_parameter_i(GL_TEXTURE_MIN_FILTER, min_filter);
+ if(mask&MAG_FILTER)
+ set_parameter_i(GL_TEXTURE_MAG_FILTER, mag_filter);
+ if(mask&MAX_ANISOTROPY)
+ set_parameter_f(GL_TEXTURE_MAX_ANISOTROPY_EXT, max_anisotropy);
+ if(mask&WRAP_S)
+ set_parameter_i(GL_TEXTURE_WRAP_S, wrap_s);
+ if(mask&WRAP_T)
+ set_parameter_i(GL_TEXTURE_WRAP_T, wrap_t);
+ if(mask&WRAP_R)
+ set_parameter_i(GL_TEXTURE_WRAP_R, wrap_r);
+ if(mask&GENERATE_MIPMAP)
+ set_parameter_i(GL_GENERATE_MIPMAP, gen_mipmap);
+ if(mask&COMPARE)
+ set_parameter_i(GL_TEXTURE_COMPARE_MODE, (compare ? GL_COMPARE_R_TO_TEXTURE : GL_NONE));
+ if(mask&COMPARE_FUNC)
+ set_parameter_i(GL_TEXTURE_COMPARE_FUNC, cmp_func);
+ if(mask&FORMAT_SWIZZLE)
+ {
+ if(ARB_direct_state_access)
+ glTextureParameteriv(id, GL_TEXTURE_SWIZZLE_RGBA, swizzle_orders+swizzle*4);
+ else
+ glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzle_orders+swizzle*4);
+ }
+}
+
+void Texture::set_parameter_i(GLenum param, int value) const