Lysa  0.0
Lysa 3D Engine
ImageManager Class Reference
+ Inheritance diagram for ImageManager:

Public Member Functions

 ImageManager (size_t capacity)
 
 ~ImageManager () override
 
void save (unique_id image_id, const std::string &filepath)
 
Imageload (const std::string &filepath, vireo::ImageFormat imageFormat=vireo::ImageFormat::R8G8B8A8_SRGB)
 
Imagecreate (const std::shared_ptr< vireo::Image > &image, const std::string &name="Image")
 
Imagecreate (const void *data, uint32 width, uint32 height, vireo::ImageFormat imageFormat=vireo::ImageFormat::R8G8B8A8_SRGB, const std::string &name="Image")
 
auto getBlankImage () const
 
auto getBlankCubeMap () const
 
auto getImages () const
 
Imageget (const std::string &name)
 
bool contains (const std::string &name) const
 
bool destroy (unique_id id) override
 
bool destroy (const Image &image) override
 
- Public Member Functions inherited from ResourcesManager< Image >
 ResourcesManager (ResourcesManager &) = delete
 
Imagecreate (Args &&...args)
 
void destroy (const std::vector< unique_id > &ids)
 
void forEach (Func &&func)
 
void forEach (Func &&func) const
 
unique_id getCapacity () const
 
bool have (const unique_id id) const
 
ResourcesManageroperator= (ResourcesManager &) = delete
 
Imageoperator[] (const unique_id id)
 
const Imageoperator[] (const unique_id id) const
 
void use (const unique_id id)
 
virtual ~ResourcesManager ()
 

Additional Inherited Members

- Protected Member Functions inherited from ResourcesManager< Image >
 ResourcesManager (const size_t capacity, const std::string &name)
 
Imageallocate (std::unique_ptr< Image > instance)
 
bool isFull () const
 
- Protected Attributes inherited from ResourcesManager< Image >
std::vector< std::unique_ptr< Image > > resources
 
std::mutex resourcesMutex
 

Constructor & Destructor Documentation

ImageManager ( size_t  capacity)

Construct a new manager

Parameters
capacityFixed capacity
~ImageManager ( )
override

Member Function Documentation

bool contains ( const std::string &  name) const

Returns true if an image with the given name exists

Parameters
nameName of the image
Image& create ( const std::shared_ptr< vireo::Image > &  image,
const std::string &  name = "Image" 
)

Creates a bitmap from an array in memory

Parameters
image
nameOptional name
Image& create ( const void *  data,
uint32  width,
uint32  height,
vireo::ImageFormat  imageFormat = vireo::ImageFormat::R8G8B8A8_SRGB,
const std::string &  name = "Image" 
)

Creates a bitmap from an array in memory

Parameters
dataPixels array
widthWidth in pixels
heightHeight in pixels
imageFormatPixel format
nameOptional name
bool destroy ( const Image res)
inlineoverridevirtual

Releases a resource by reference, decrementing its reference counter.

Parameters
resResource to destroy.
Returns
true if the resource was actually freed, false if references remain.

Reimplemented from lysa::ResourcesManager< Image >::destroy()

bool destroy ( unique_id  id)
overridevirtual

Releases a resource by ID, decrementing its reference counter. The slot is returned to the free list only when the counter reaches zero.

Parameters
idUnique identifier of the resource to destroy.
Returns
true if the resource was actually freed, false if references remain.

Reimplemented from lysa::ResourcesManager< Image >::destroy()

Image& get ( const std::string &  name)

Returns the image with the given name, or raise an Exception if not found

Parameters
nameName of the image (as stored at creation)
auto getBlankCubeMap ( ) const
inline

Returns the default cubemap blank image used as a safe fallback.

auto getBlankImage ( ) const
inline

Returns the default 2D blank image used as a safe fallback.

auto getImages ( ) const
inline

Return the global GPU image array

Image& load ( const std::string &  filepath,
vireo::ImageFormat  imageFormat = vireo::ImageFormat::R8G8B8A8_SRGB 
)

Load a bitmap from a file.
Supports JPEG and PNG formats

Parameters
filepathSource file URI
imageFormatImage pixel format
void save ( unique_id  image_id,
const std::string &  filepath 
)

Save an image into a file.
Supports PNG and HDR formats.

Parameters
image_idImage
filepathDestination file URI