X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fresources.cpp;h=22814cb820525809836226b2a455afd844d668cd;hp=79c5e85fbe47764e0cca300f15c8acb3ff350450;hb=HEAD;hpb=9d696772b2194b67d8e3e4da11169900eab58c0d diff --git a/source/resources.cpp b/source/resources.cpp deleted file mode 100644 index 79c5e85f..00000000 --- a/source/resources.cpp +++ /dev/null @@ -1,92 +0,0 @@ -#include -#include "animation.h" -#include "armature.h" -#include "font.h" -#include "keyframe.h" -#include "material.h" -#include "mesh.h" -#include "object.h" -#include "pose.h" -#include "program.h" -#include "resourcemanager.h" -#include "resources.h" -#include "technique.h" -#include "texture2d.h" -#include "texturecube.h" - -using namespace std; - -namespace Msp { -namespace GL { - -Resources::Resources(): - default_tex_filter(LINEAR_MIPMAP_LINEAR), - srgb_conversion(false), - resource_manager(0) -{ - add_type().suffix(".anim").keyword("animation"); - add_type().suffix(".arma").keyword("armature"); - add_type().keyword("font"); - add_type().suffix(".kframe").keyword("keyframe"); - add_type().suffix(".mat").keyword("material"); - add_type().keyword("mesh"); - add_type().keyword("object"); - add_type().keyword("pose"); - add_type().keyword("shader"); - add_type().suffix(".tech").keyword("technique"); - add_type().base().suffix(".tex2d").suffix(".png").suffix(".jpg").keyword("texture2d").creator(&Resources::create_texture2d); - add_type().base().suffix(".texcb").keyword("texture_cube"); -} - -void Resources::set_default_texture_filter(TextureFilter tf) -{ - default_tex_filter = tf; -} - -void Resources::set_srgb_conversion(bool c) -{ - srgb_conversion = c; -} - -void Resources::set_resource_manager(ResourceManager *m) -{ - resource_manager = m; -} - -Texture2D *Resources::create_texture2d(const string &name) -{ - string ext = FS::extpart(name); - if(ext==".tex2d") - return 0; - - if(RefPtr io = open_from_sources(name)) - { - Graphics::Image image; - if(!resource_manager) - image.load_io(*io); - - RefPtr tex = new GL::Texture2D(resource_manager); - - if(default_tex_filter==NEAREST_MIPMAP_NEAREST || default_tex_filter==NEAREST_MIPMAP_LINEAR || - default_tex_filter==LINEAR_MIPMAP_NEAREST || default_tex_filter==LINEAR_MIPMAP_LINEAR) - { - tex->set_generate_mipmap(true); - tex->set_mag_filter(LINEAR); - } - else - tex->set_mag_filter(default_tex_filter); - tex->set_min_filter(default_tex_filter); - - // TODO Somehow pass the srgb flag if a resource manager is in use - if(resource_manager) - resource_manager->set_resource_location(*tex, *this, name); - else - tex->image(image, srgb_conversion); - return tex.release(); - } - - return 0; -} - -} // namespace GL -} // namespace Msp