
#include <WFX/scene/MaterialManager.h>

using namespace WFX;
using namespace WFX::scene;
using namespace std;

MaterialManager::MaterialManager() {
}

MaterialManager::~MaterialManager() {
    //delete Materials
    std::map<std::string, Material*>::iterator it;
    for(it = Materials.begin(); it!=Materials.end(); it++) {
        delete (*it).second;
    }
}

void MaterialManager::regMaterial(Material* m) {
    Materials[m->getName()] = m; 
}

Material* MaterialManager::getMaterial(const std::string& str) {
    if (Materials.find(str) == Materials.end())
        THROW("Material not found" << str);

    Material* ptr = Materials[str];
    return ptr;
}


