-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,
- GL_BLUE, GL_GREEN, GL_RED, GL_ALPHA
-};
-
-Texture::Texture(GLenum t, ResourceManager *m):
- id(0),
- target(t),
- format(RGB8),
- storage_fmt(RGB8),
- swizzle(NO_SWIZZLE),
- use_srgb_format(false),
- auto_gen_mipmap(false),
- default_sampler(*this)
-{
- if(m)
- set_manager(m);
- else
- generate_id();
-}
-
-Texture::~Texture()
-{
- while(TexUnit *unit = TexUnit::find_unit(this))
- unbind_from(unit->get_index());
-
- if(id)
- glDeleteTextures(1, &id);
-}
-
-void Texture::generate_id()
-{
- if(id)
- throw invalid_operation("Texture::generate_id");
- if(ARB_direct_state_access)
- glCreateTextures(target, 1, &id);
- else
- glGenTextures(1, &id);
-
-#ifdef DEBUG
- if(!debug_name.empty() && KHR_debug)
- glObjectLabel(GL_TEXTURE, id, debug_name.size(), debug_name.c_str());
-#endif
-}