From 51f7699966ab856c873648ee25621b80421f8c8f Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Mon, 16 Sep 2024 17:34:05 +0200 Subject: loading images work through resource manager, however needs return fixing. cause right now static cast needs to be done outside --- resource-manager/resource_fabricator.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 resource-manager/resource_fabricator.cpp (limited to 'resource-manager/resource_fabricator.cpp') 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 +#include + +#include "resource_fabricator.h" +#include "resource.h" +#include "Image_asset.h" +#include "Audio_asset.h" + +#include + + +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; +} -- cgit v1.2.3