forked from floooh/oryol
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
333 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//------------------------------------------------------------------------------ | ||
// AssetLoader.cc | ||
//------------------------------------------------------------------------------ | ||
#include "Pre.h" | ||
#include "AssetLoader.h" | ||
|
||
namespace Oryol { | ||
|
||
OryolClassImpl(AssetLoader); | ||
|
||
//------------------------------------------------------------------------------ | ||
void | ||
AssetLoader::Attached() { | ||
// empty | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
void | ||
AssetLoader::Detached() { | ||
// empty | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
bool | ||
AssetLoader::TryLoad(const Id& /*id*/, const Ptr<Stream>& /*data*/) { | ||
return false; | ||
} | ||
|
||
} // namespace Oryol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#pragma once | ||
//------------------------------------------------------------------------------ | ||
/** | ||
@class Oryol::assetCreator | ||
@ingroup Assets | ||
@brief wrapper class for directly creating assets | ||
This class contains entirely of specialized template methods | ||
to forward a resource creation request to a specific Module | ||
and return the resulting resource id as AssetId. Each set of | ||
specialization methods should live in its own source code | ||
(compilation unit) to make sure that unused Modules are not | ||
linked in. | ||
*/ | ||
#include "IO/Stream/Stream.h" | ||
#include "Assets/Core/assetRegistry.h" | ||
|
||
namespace Oryol { | ||
namespace _priv { | ||
|
||
class assetCreator { | ||
public: | ||
/// setup the asset creator | ||
void Setup(assetRegistry* registry); | ||
/// discard the asset creator | ||
void Discard(); | ||
|
||
/// directly create a shared, use-counted asset | ||
template<class SETUP> Id Create(const SETUP& setup, assetRegistry* registry); | ||
/// directly create a shared, use-count asset with data | ||
template<class SETUP> Id Create(const SETUP& setup, const Ptr<Stream>& data, assetRegistry* registry); | ||
/// allocate a resource (for async resource loading) | ||
template<class SETUP> Id Alloc(const SETUP& setup, Id placeholder, assetRegistry* registry); | ||
/// setup a previously allocated resource from data (for async resource loading) | ||
template<class SETUP> void Init(const Id& id, const SETUP& setup, const Ptr<Stream>& data); | ||
|
||
/// one-time register a push-label function | ||
void regFuncsOnce(void(*push)(uint8), uint8(*pop)(), void(*discard)(uint8)); | ||
}; | ||
|
||
} // namespace _priv | ||
} // namespace Oryol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//------------------------------------------------------------------------------ | ||
// assetCreator_Gfx.cc | ||
//------------------------------------------------------------------------------ | ||
#include "Pre.h" | ||
#include "assetCreator.h" | ||
#include "Gfx/Gfx.h" | ||
|
||
namespace Oryol { | ||
namespace _priv { | ||
|
||
//------------------------------------------------------------------------------ | ||
template<class SETUP> Id | ||
assetCreator::Create(const SETUP& setup, assetRegistry* registry) { | ||
this->regFuncsOnce(Gfx::PushResourceLabel, Gfx::PopResourceLabel, Gfx::DiscardResources); | ||
Id resId = Gfx::CreateResource(setup); | ||
registry->Add(setup.Locator, resId); | ||
return resId; | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
template<class SETUP> Id | ||
assetCreator::Create(const SETUP& setup, const Ptr<Stream>& data, assetRegistry* registry) { | ||
this->regFuncsOnce(Gfx::PushResourceLabel, Gfx::PopResourceLabel, Gfx::DiscardResources); | ||
Id resId = Gfx::CreateResource(setup, data); | ||
registry->Add(setup.Locator, resId); | ||
return resId; | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
template<class SETUP> Id | ||
assetCreator::Alloc(const SETUP& setup, Id placeholder, assetRegistry* registry) { | ||
this->regFuncsOnce(Gfx::PushResourceLabel, Gfx::PopResourceLabel, Gfx::DiscardResources); | ||
Id resId = Gfx::AllocResource(setup, placeholder); | ||
registry->Add(setup.Locator, resId); | ||
return resId; | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
template<class SETUP> void | ||
assetCreator::Init(const Id& id, const SETUP& setup, const Ptr<Stream>& data) { | ||
Gfx::InitResource(id, setup, data); | ||
} | ||
|
||
} // namespace _priv | ||
} // namespace Oryol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.