glTexParameteri(target, param, value);
}
-bool Texture::can_generate_mipmap()
-{
- return EXT_framebuffer_object;
-}
-
void Texture::generate_mipmap()
{
// glGenerateMipmap is defined here
}
}
-void Texture::set_auto_generate_mipmap(bool gm)
-{
- if(gm)
- static Require _req(EXT_framebuffer_object);
-
- auto_gen_mipmap = gm;
-}
-
void Texture::load_image(const string &fn, bool)
{
load_image(fn, 0U);
add("mipmap_levels", &Loader::mipmap_levels);
}
+void Texture::Loader::finish()
+{
+ if(obj.auto_gen_mipmap)
+ obj.generate_mipmap();
+}
+
void Texture::Loader::load_external_image(Graphics::Image &img, const string &fn)
{
RefPtr<IO::Seekable> io = get_collection().open_raw(fn);
void Texture::Loader::generate_mipmap(bool gm)
{
- obj.set_auto_generate_mipmap(gm);
+ obj.auto_gen_mipmap = gm;
}
void Texture::Loader::image_data(const string &data)
private:
void init();
+ virtual void finish();
+
protected:
void load_external_image(Graphics::Image &, const std::string &);
public:
PixelFormat get_format() const { return format; }
- static bool can_generate_mipmap();
-
void generate_mipmap();
- /** Sets automatic mipmap generation. If enabled, mipmaps are generated
- when a texture image is uploaded. */
- void set_auto_generate_mipmap(bool);
-
- /// Deprecated. Use set_auto_generate_mipmap instead.
- DEPRECATED void set_generate_mipmap(bool g) { set_auto_generate_mipmap(g); }
-
/// Loads a Graphics::Image from a file and uploads it to the texture.
virtual void load_image(const std::string &, unsigned = 0);
glTexImage1D(target, level, fmt, get_level_size(level), 0, comp, type, data);
allocated |= 1<<level;
- if(auto_gen_mipmap && level==0)
- {
- generate_mipmap();
- allocated |= (1<<levels)-1;
- }
}
void Texture1D::image(unsigned level, PixelComponents comp, DataType type, const void *data)
bind_scratch();
glTexSubImage1D(target, level, x, wd, comp, type, data);
}
-
- if(auto_gen_mipmap && level==0)
- generate_mipmap();
}
void Texture1D::sub_image(unsigned level, int x, unsigned wd, PixelComponents comp, DataType type, const void *data)
glTexImage2D(target, level, fmt, size.x, size.y, 0, comp, type, data);
allocated |= 1<<level;
- if(auto_gen_mipmap && level==0)
- {
- generate_mipmap();
- allocated |= (1<<levels)-1;
- }
}
void Texture2D::image(unsigned level, PixelComponents comp, DataType type, const void *data)
bind_scratch();
glTexSubImage2D(target, level, x, y, wd, ht, comp, type, data);
}
-
- if(auto_gen_mipmap && level==0)
- generate_mipmap();
}
void Texture2D::sub_image(unsigned level, int x, int y, unsigned wd, unsigned ht, PixelComponents comp, DataType type, const void *data)
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pixel_buffer.get_id());
texture.image(image, 0, true);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
+ if(texture.auto_gen_mipmap)
+ texture.generate_mipmap();
}
++phase;
glTexImage3D(target, level, fmt, size.x, size.y, size.z, 0, comp, type, data);
allocated |= 1<<level;
- if(auto_gen_mipmap && level==0)
- {
- generate_mipmap();
- allocated |= (1<<levels)-1;
- }
}
void Texture3D::image(unsigned level, PixelComponents comp, DataType type, const void *data)
bind_scratch();
glTexSubImage3D(target, level, x, y, z, wd, ht, dp, comp, type, data);
}
-
- if(auto_gen_mipmap && level==0)
- generate_mipmap();
}
void Texture3D::sub_image(unsigned level, int x, int y, int z, unsigned wd, unsigned ht, unsigned dp, PixelComponents comp, DataType type, const void *data)
{
allocated |= 1<<get_face_index(face);
if((allocated&63)==63)
- {
allocated |= 64;
- if(auto_gen_mipmap && level==0 && (allocated&63)==63)
- {
- generate_mipmap();
- allocated |= (64<<levels)-1;
- }
- }
}
else if(!(allocated&(64<<level)))
{
bind_scratch();
glTexSubImage2D(face, level, x, y, wd, ht, comp, type, data);
}
-
- if(auto_gen_mipmap && level==0)
- generate_mipmap();
}
void TextureCube::sub_image(TextureCubeFace face, unsigned level, int x, int y, unsigned wd, unsigned ht, PixelComponents comp, DataType type, const void *data)