29 #ifndef THOR_SFMLLOADERS_HPP
30 #define THOR_SFMLLOADERS_HPP
33 #include <Thor/Resources/Detail/ResourceLoaderHelpers.hpp>
35 #include <Aurora/Meta/Templates.hpp>
57 return detail::makeResourceLoader<R>(
58 [=] (R& resource) {
return resource.loadFromFile(filename); },
59 detail::Tagger(
"File") << filename);
66 template <
class R,
typename T>
69 return detail::makeResourceLoader<R>(
70 [=] (R& resource) {
return resource.loadFromFile(filename, arg1); },
71 detail::Tagger(
"File") << filename << arg1);
78 template <
class R,
typename T,
typename U>
81 return detail::makeResourceLoader<R>(
82 [=] (R& resource) {
return resource.loadFromMemory(arg1, arg2); },
83 detail::Tagger(
"Memory") << arg1 << arg2);
91 template <
class R,
typename T,
typename U,
typename V>
94 return detail::makeResourceLoader<R>(
95 [=] (R& resource) {
return resource.loadFromMemory(arg1, arg2, arg3); },
96 detail::Tagger(
"Memory") << arg1 << arg2 << arg3);
105 return detail::makeResourceLoader<R>(
106 [&] (R& resource) {
return resource.loadFromStream(stream); },
107 detail::Tagger(
"Stream") << &stream);
117 return detail::makeResourceLoader<R>(
118 [&] (R& resource) {
return resource.loadFromStream(vertexShaderStream, fragmentShaderStream); },
119 detail::Tagger(
"Stream") << &vertexShaderStream << &fragmentShaderStream);
126 template <
class R,
typename T>
128 AURORA_ENABLE_IF(!std::is_base_of<sf::InputStream, T>::value))
130 return detail::makeResourceLoader<R>(
131 [&stream, arg1] (R& resource) {
return resource.loadFromStream(stream, arg1); },
132 detail::Tagger(
"Stream") << &stream << arg1);
144 return detail::makeResourceLoader<R>(
145 [=] (R& resource) {
return resource.loadFromSamples(samples, sampleCount, channelCount, sampleRate); },
146 detail::Tagger(
"Samples") << samples << sampleCount << channelCount << sampleRate);
156 return detail::makeResourceLoader<R>(
157 [=] (R& resource) ->
bool
159 resource.create(width, height, pixels);
162 detail::Tagger(
"Pixels") << width << height << pixels);
172 return detail::makeResourceLoader<R>(
173 [=] (R& resource) ->
bool
175 resource.create(width, height, color);
178 detail::Tagger(
"Color") << width << height << color);
188 return detail::makeResourceLoader<R>(
189 [&image, area] (R& resource) {
return resource.loadFromImage(image, area); },
190 detail::Tagger(
"Image") << &image << area);
199 #endif // THOR_SFMLLOADERS_HPP
Definition: AnimationMap.hpp:42
ResourceLoader< R > fromFile(const std::string &filename)
Load the resource from a file on hard disk.
Definition: SfmlLoaders.hpp:55
ResourceLoader< R > fromImage(const sf::Image &image, const sf::IntRect area=sf::IntRect())
Load the resource (usually sf::Texture) from a sf::Image.
Definition: SfmlLoaders.hpp:186
ResourceLoader< R > fromStream(sf::InputStream &stream)
Load the resource from an input stream.
Definition: SfmlLoaders.hpp:103
ResourceLoader< R > fromPixels(unsigned int width, unsigned int height, const sf::Uint8 *pixels)
Load resource (usually sf::Image) from array of pixels.
Definition: SfmlLoaders.hpp:154
ResourceLoader< R > fromSamples(const sf::Int16 *samples, std::size_t sampleCount, unsigned int channelCount, unsigned int sampleRate)
Load sf::SoundBuffer from array of audio samples in memory.
Definition: SfmlLoaders.hpp:142
Class storing loading information for resources.
Definition: ResourceLoader.hpp:48
Class template thor::ResourceLoader.
ResourceLoader< R > fromColor(unsigned int width, unsigned int height, const sf::Color &color)
Load resource (usually sf::Image) from size and fill color.
Definition: SfmlLoaders.hpp:170
ResourceLoader< R > fromMemory(T arg1, U arg2)
Load the resource from a file in memory.
Definition: SfmlLoaders.hpp:79