aboutsummaryrefslogtreecommitdiff
path: root/resource-manager/resource_fabricator.cpp
blob: 2b1f5f70d6f98194cd74fb11ef93f8eac26ea5b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <filesystem>
#include <string>

#include "resource_fabricator.h"
#include "resource.h"
#include "Image_asset.h"
#include "Audio_asset.h"

#include <SDL2/SDL_image.h>


Resource* ResourceFactory::create_resource(const Constants::FILE_PATH &file_path){

	std::string extension = std::filesystem::path(file_path).extension();

	if( extension == Constants::PNG_EXT ) {
		return new Image(file_path);
	}
	else if ( extension == Constants::OGG_EXT ){
		return new Audio;
	}

	return nullptr;
}