X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Ftexture.cpp;h=877e4d10c38f6ab60d64fd7166e4e56d5d1f2674;hb=8653af6d620206c1a8bab284721256e9ea4e3b74;hp=b40046705b32bdfbecd459b56ce5e9b7c81ae4d9;hpb=7b569bbfcfb65d8d88b47ac42ee1df6a7d27e784;p=libs%2Fgl.git diff --git a/source/core/texture.cpp b/source/core/texture.cpp index b4004670..877e4d10 100644 --- a/source/core/texture.cpp +++ b/source/core/texture.cpp @@ -13,7 +13,7 @@ using namespace std; namespace Msp { namespace GL { -int Texture::swizzle_orders[] = +const int Texture::swizzle_orders[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA, GL_RED, GL_RED, GL_RED, GL_ONE, @@ -26,8 +26,8 @@ Texture *Texture::scratch_binding = 0; Texture::Texture(GLenum t, ResourceManager *m): id(0), target(t), - format(RGB8), - storage_fmt(RGB8), + format(NO_PIXELFORMAT), + storage_fmt(format), swizzle(NO_SWIZZLE), use_srgb_format(false), auto_gen_mipmap(false) @@ -133,11 +133,6 @@ void Texture::set_parameter_i(GLenum param, int value) const glTexParameteri(target, param, value); } -bool Texture::can_generate_mipmap() -{ - return EXT_framebuffer_object; -} - void Texture::generate_mipmap() { // glGenerateMipmap is defined here @@ -152,19 +147,6 @@ void Texture::generate_mipmap() } } -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); -} - void Texture::load_image(const string &fn, unsigned lv) { Graphics::Image img; @@ -173,11 +155,6 @@ void Texture::load_image(const string &fn, unsigned lv) image(img, lv); } -void Texture::image(const Graphics::Image &img, bool) -{ - image(img, 0U); -} - void Texture::set_debug_name(const string &name) { #ifdef DEBUG @@ -235,6 +212,12 @@ void Texture::Loader::init() 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 = get_collection().open_raw(fn); @@ -269,7 +252,7 @@ void Texture::Loader::external_image_common(const string &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)