NAP
Public Member Functions | Public Attributes | List of all members
ImageFromFile Class Reference

#include <imagefromfile.h>

Public Member Functions

 ImageFromFile (Core &core, const std::string &imgPath)
 
 ImageFromFile (Core &core)
 
virtual bool init (utility::ErrorState &errorState) override
 
- Public Member Functions inherited from Image
 Image (Core &core)
 
BitmapgetBitmap ()
 
void update ()
 
void asyncGetData ()
 
void update (const void *data, int width, int height, int pitch, ESurfaceChannels channels)
 
void update (const void *data, const SurfaceDescriptor &surfaceDescriptor)
 
void asyncGetData (Bitmap &bitmap)
 
void asyncGetData (std::function< void(const void *, size_t)> copyFunction)
 
- Public Member Functions inherited from Texture2D
 Texture2D (Core &core)
 
virtual ~Texture2D () override
 
bool init (const SurfaceDescriptor &descriptor, bool generateMipMaps, const glm::vec4 &clearColor, VkImageUsageFlags requiredFlags, utility::ErrorState &errorState)
 
bool init (const SurfaceDescriptor &descriptor, bool generateMipMaps, VkImageUsageFlags requiredFlags, utility::ErrorState &errorState)
 
bool init (const SurfaceDescriptor &descriptor, bool generateMipMaps, void *initialData, VkImageUsageFlags requiredFlags, utility::ErrorState &errorState)
 
const glm::vec2 getSize () const
 
int getWidth () const
 
int getHeight () const
 
void update (const void *data, int width, int height, int pitch, ESurfaceChannels channels)
 
void update (const void *data, const SurfaceDescriptor &surfaceDescriptor)
 
virtual uint getLayerCount () const override
 
virtual uint getMipLevels () const override
 
virtual const ImageDatagetHandle () const override
 
void asyncGetData (Bitmap &bitmap)
 
void asyncGetData (std::function< void(const void *, size_t)> copyFunction)
 
- Public Member Functions inherited from Texture
 Texture (Core &core)
 
virtual ~Texture ()
 
virtual VkImageLayout getTargetLayout () const
 
VkFormat getFormat () const
 
const SurfaceDescriptorgetDescriptor () const
 
RenderServicegetRenderService ()
 
const RenderServicegetRenderService () const
 
virtual void onDestroy () override
 
- Public Member Functions inherited from Resource
 Resource ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Public Attributes

std::string mImagePath
 Property: 'ImagePath' Path to the image on disk to load. More...
 
bool mGenerateLods = true
 Property: 'GenerateLods' If LODs are generated for this image. More...
 
- Public Attributes inherited from Texture2D
EUsage mUsage = EUsage::Static
 Property: 'Usage' If this texture is updated frequently or considered static. More...
 
- Public Attributes inherited from Texture
nap::Signal textureDestroyed
 Signal that is triggered before texture is destroyed. More...
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Additional Inherited Members

- Public Types inherited from Texture
enum  EUsage { Static, DynamicRead, DynamicWrite }
 
- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 
- Protected Types inherited from Texture2D
using TextureReadCallback = std::function< void(void *data, size_t sizeInBytes)>
 
- Protected Member Functions inherited from Texture2D
virtual ImageDatagetHandle () override
 
bool initInternal (const SurfaceDescriptor &descriptor, bool generateMipMaps, VkImageUsageFlags requiredFlags, utility::ErrorState &errorState)
 
void upload (VkCommandBuffer commandBuffer)
 
void download (VkCommandBuffer commandBuffer)
 
void notifyDownloadReady (int frameIndex)
 
void clearDownloads ()
 
- Protected Member Functions inherited from Texture
virtual void clear (VkCommandBuffer commandBuffer)
 
void requestClear ()
 
- Protected Attributes inherited from Texture2D
ImageData mImageData
 2D Texture vulkan image buffers More...
 
std::vector< BufferDatamStagingBuffers
 All vulkan staging buffers, 1 when static or using dynamic read, no. of frames in flight when dynamic write. More...
 
int mCurrentStagingBufferIndex = -1
 Currently used staging buffer. More...
 
size_t mImageSizeInBytes = -1
 Size in bytes of texture. More...
 
std::vector< TextureReadCallbackmReadCallbacks
 Number of callbacks based on number of frames in flight. More...
 
std::vector< int > mDownloadStagingBufferIndices
 Staging buffer indices associated with a frameindex. More...
 
uint32 mMipLevels = 1
 Total number of generated mip-maps. More...
 
- Protected Attributes inherited from Texture
RenderServicemRenderService
 Reference to the render service. More...
 
SurfaceDescriptor mDescriptor
 Texture description. More...
 
VkFormat mFormat = VK_FORMAT_UNDEFINED
 Vulkan texture format. More...
 
VkClearColorValue mClearColor = { 0.0f, 0.0f, 0.0f, 0.0f }
 Color used for clearing the texture. More...
 

Description

Contains both the CPU and GPU data of a 2D image that is loaded from disk. The bitmap is loaded on initialization and scheduled for upload, into a texture on the GPU, on success. Mip-maps are automatically generated when 'GenerateLods' is set to true.

Inheritance diagram for ImageFromFile:
[legend]
Collaboration diagram for ImageFromFile:
[legend]

Constructor & Destructor Documentation

◆ ImageFromFile() [1/2]

ImageFromFile ( Core core,
const std::string &  imgPath 
)
Parameters
corethe core instance.
imgPathpath to the image on disk.

◆ ImageFromFile() [2/2]

ImageFromFile ( Core core)
Parameters
corethe core instance

Member Function Documentation

◆ init()

virtual bool init ( utility::ErrorState errorState)
overridevirtual

Loads the image from disk and schedules the upload to the GPU on success.

Parameters
errorStatecontains the error when initialization fails
Returns
true when successful, otherwise false.

Reimplemented from Object.

Member Data Documentation

◆ mGenerateLods

bool mGenerateLods = true

Property: 'GenerateLods' If LODs are generated for this image.

◆ mImagePath

std::string mImagePath

Property: 'ImagePath' Path to the image on disk to load.