diff --git a/headers/enduro2d/high/_high.hpp b/headers/enduro2d/high/_high.hpp index b8e5e2aa..7397e5a5 100644 --- a/headers/enduro2d/high/_high.hpp +++ b/headers/enduro2d/high/_high.hpp @@ -15,6 +15,7 @@ namespace e2d class text_asset; class image_asset; class binary_asset; + class texture_asset; template < typename T > class asset_cache; diff --git a/headers/enduro2d/high/assets.hpp b/headers/enduro2d/high/assets.hpp index 2f9c4f00..9250ed65 100644 --- a/headers/enduro2d/high/assets.hpp +++ b/headers/enduro2d/high/assets.hpp @@ -41,4 +41,10 @@ namespace e2d using content_asset::content_asset; static std::shared_ptr load(library& library, str_view address); }; + + class texture_asset final : public content_asset { + public: + using content_asset::content_asset; + static std::shared_ptr load(library& library, str_view address); + }; } diff --git a/sources/enduro2d/high/assets.cpp b/sources/enduro2d/high/assets.cpp index 29dc3c07..5b03ebda 100644 --- a/sources/enduro2d/high/assets.cpp +++ b/sources/enduro2d/high/assets.cpp @@ -46,13 +46,13 @@ namespace e2d std::shared_ptr image_asset::load(library& library, str_view address) { const auto image_data = library.load_asset(address); - if ( !image_data) { + if ( !image_data ) { return nullptr; } image content; if ( !images::try_load_image(content, image_data->content()) ) { - the().error("ASSETS: Failed to load image asset:\n" + the().error("ASSETS: Failed to create image asset:\n" "--> Address: %0", address); return nullptr; @@ -87,4 +87,25 @@ namespace e2d return std::make_shared(std::move(content)); } + + // + // texture_asset + // + + std::shared_ptr texture_asset::load(library& library, str_view address) { + const auto texture_data = library.load_asset(address); + if ( !texture_data ) { + return nullptr; + } + + const auto content = the().create_texture(texture_data->content()); + if ( !content ) { + the().error("ASSETS: Failed to create texture asset:\n" + "--> Address: %0", + address); + return nullptr; + } + + return std::make_shared(content); + } }