aboutsummaryrefslogtreecommitdiff
path: root/resource-manager/resource_fabricator.cpp
blob: 03e3f74cf3008c8433d303102918e6375a5e8512 (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
27
28
29
30
#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 ) {
		Image* img = new Image;
		img->surface = IMG_Load(file_path.c_str());
		return img;
	}
	else if ( extension == Constants::OGG_EXT ){
		return new Audio;
	}

	return nullptr;
}