int LoadResource(const std::string location, ResourceType type)
{
bool resLoaded = isLoaded(location, type);
if(resLoaded) {return -1;} // Tells the resource was already loaded.
if(type == R_TEXTURE)
{
// Load the texture
Video::Texture texture(location.c_str());
Resource<Video::Texture>* res = new Resource<Video::Texture>(texture, location);
// Load the texture into a resource template, then to a shared_ptr object.
std::shared_ptr<Resource<Video::Texture>> tmpSRes(res);
// Add the shared_ptr to the texture database.
textures.push_back(tmpSRes);
}
elseif(type == R_MESH)
{
Mesh mesh;
mesh.LoadOBJT(location.c_str(), std::shared_ptr<Resource<Video::Texture>>(nullptr));
}
// Now since a resource was loaded, we can safely add 1 to the numResources variable...
numResources++;
return 0;
}
bool isLoaded(const std::string location, ResourceType type) const
{
// Based on the type, we loop through our
// resource data base and check if the texture is loaded.
// (Look at each resource's HD location, and based on that we check if it matches the
// resource we'd like to load's HD location. If it does, we return true)
switch(type)
{
case R_TEXTURE:
for(unsignedint r = 0; r < textures.size(); r++)
{
if(location == textures[r]->getID())
{
returntrue;
}
}
break;
case R_MESH:
for(unsignedint r = 0; r < meshes.size(); r++)
{
if(location == meshes[r]->getID())
{
returntrue;
}
}
break;
case R_MODEL:
for(unsignedint r = 0; r < models.size(); r++)
{
if(location == models[r]->getID())
{
returntrue;
}
}
break;
default:
returnfalse;
break;
}
// If there wasn't a match
returnfalse;
}