diff options
author | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2016-09-30 10:49:55 +0200 |
---|---|---|
committer | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2016-09-30 17:41:45 +0200 |
commit | 11cbbeb17ed0f5ff369046c1a194e0a31863f207 (patch) | |
tree | a1f0df8912a1c8a461cd8323f0a76b6cc3e7f3a7 /scene/io/resource_format_image.cpp | |
parent | dabcabe9815612c7ef1c99909b14d632f13df165 (diff) |
Respect texture .flags files on export
Diffstat (limited to 'scene/io/resource_format_image.cpp')
-rw-r--r-- | scene/io/resource_format_image.cpp | 118 |
1 files changed, 63 insertions, 55 deletions
diff --git a/scene/io/resource_format_image.cpp b/scene/io/resource_format_image.cpp index f3a0eaa8c4..55ad23ba93 100644 --- a/scene/io/resource_format_image.cpp +++ b/scene/io/resource_format_image.cpp @@ -136,61 +136,7 @@ RES ResourceFormatLoaderImage::load(const String &p_path, const String& p_origin #endif - uint32_t flags=0; - - FileAccess *f2 = FileAccess::open(p_path+".flags",FileAccess::READ); - Map<String,bool> flags_found; - if (f2) { - - while(!f2->eof_reached()) { - String l2 = f2->get_line(); - int eqpos = l2.find("="); - if (eqpos!=-1) { - String flag=l2.substr(0,eqpos).strip_edges(); - String val=l2.substr(eqpos+1,l2.length()).strip_edges().to_lower(); - flags_found[flag]=(val=="true" || val=="1")?true:false; - } - } - memdelete(f2); - } - - - if (flags_found.has("filter")) { - if (flags_found["filter"]) - flags|=Texture::FLAG_FILTER; - } else if (bool(GLOBAL_DEF("image_loader/filter",true))) { - flags|=Texture::FLAG_FILTER; - } - - - if (flags_found.has("gen_mipmaps")) { - if (flags_found["gen_mipmaps"]) - flags|=Texture::FLAG_MIPMAPS; - } else if (bool(GLOBAL_DEF("image_loader/gen_mipmaps",true))) { - flags|=Texture::FLAG_MIPMAPS; - } - - if (flags_found.has("repeat")) { - if (flags_found["repeat"]) - flags|=Texture::FLAG_REPEAT; - } else if (bool(GLOBAL_DEF("image_loader/repeat",true))) { - flags|=Texture::FLAG_REPEAT; - } - - if (flags_found.has("anisotropic")) { - if (flags_found["anisotropic"]) - flags|=Texture::FLAG_ANISOTROPIC_FILTER; - } - - if (flags_found.has("tolinear")) { - if (flags_found["tolinear"]) - flags|=Texture::FLAG_CONVERT_TO_LINEAR; - } - - if (flags_found.has("mirroredrepeat")) { - if (flags_found["mirroredrepeat"]) - flags|=Texture::FLAG_MIRRORED_REPEAT; - } + uint32_t flags=load_image_flags(p_path); if (debug_load_times) begtime=OS::get_singleton()->get_ticks_usec(); @@ -214,6 +160,68 @@ RES ResourceFormatLoaderImage::load(const String &p_path, const String& p_origin } +uint32_t ResourceFormatLoaderImage::load_image_flags(const String &p_path) { + + + FileAccess *f2 = FileAccess::open(p_path+".flags",FileAccess::READ); + Map<String,bool> flags_found; + if (f2) { + + while(!f2->eof_reached()) { + String l2 = f2->get_line(); + int eqpos = l2.find("="); + if (eqpos!=-1) { + String flag=l2.substr(0,eqpos).strip_edges(); + String val=l2.substr(eqpos+1,l2.length()).strip_edges().to_lower(); + flags_found[flag]=(val=="true" || val=="1")?true:false; + } + } + memdelete(f2); + } + + + uint32_t flags=0; + + if (flags_found.has("filter")) { + if (flags_found["filter"]) + flags|=Texture::FLAG_FILTER; + } else if (bool(GLOBAL_DEF("image_loader/filter",true))) { + flags|=Texture::FLAG_FILTER; + } + + + if (flags_found.has("gen_mipmaps")) { + if (flags_found["gen_mipmaps"]) + flags|=Texture::FLAG_MIPMAPS; + } else if (bool(GLOBAL_DEF("image_loader/gen_mipmaps",true))) { + flags|=Texture::FLAG_MIPMAPS; + } + + if (flags_found.has("repeat")) { + if (flags_found["repeat"]) + flags|=Texture::FLAG_REPEAT; + } else if (bool(GLOBAL_DEF("image_loader/repeat",true))) { + flags|=Texture::FLAG_REPEAT; + } + + if (flags_found.has("anisotropic")) { + if (flags_found["anisotropic"]) + flags|=Texture::FLAG_ANISOTROPIC_FILTER; + } + + if (flags_found.has("tolinear")) { + if (flags_found["tolinear"]) + flags|=Texture::FLAG_CONVERT_TO_LINEAR; + } + + if (flags_found.has("mirroredrepeat")) { + if (flags_found["mirroredrepeat"]) + flags|=Texture::FLAG_MIRRORED_REPEAT; + } + + return flags; +} + bool ResourceFormatLoaderImage::handles_type(const String& p_type) const { return ObjectTypeDB::is_type(p_type,"Texture") || ObjectTypeDB::is_type(p_type,"CubeMap"); |