aboutsummaryrefslogtreecommitdiff
path: root/resource-manager/resource_fabricator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'resource-manager/resource_fabricator.cpp')
-rw-r--r--resource-manager/resource_fabricator.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/resource-manager/resource_fabricator.cpp b/resource-manager/resource_fabricator.cpp
new file mode 100644
index 0000000..03e3f74
--- /dev/null
+++ b/resource-manager/resource_fabricator.cpp
@@ -0,0 +1,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;
+}