Wasabi
|
#include <WImage.hpp>
Public Member Functions | |
virtual std::string | GetTypeName () const override |
virtual void | SetID (uint32_t newID) override |
virtual void | SetName (std::string newName) override |
WImage (class Wasabi *const app, uint32_t ID=0) | |
WError | CreateFromPixelsArray (void *pixels, uint32_t width, uint32_t height, VkFormat format, W_IMAGE_CREATE_FLAGS flags=W_IMAGE_CREATE_TEXTURE) |
WError | CreateFromPixelsArray (void *pixels, uint32_t width, uint32_t height, uint32_t depth, VkFormat format, uint32_t arraySize=1, W_IMAGE_CREATE_FLAGS flags=W_IMAGE_CREATE_TEXTURE) |
WError | Load (std::string filename, W_IMAGE_CREATE_FLAGS flags=W_IMAGE_CREATE_TEXTURE) |
WError | CopyFrom (WImage *const image, W_IMAGE_CREATE_FLAGS flags=W_IMAGE_CREATE_TEXTURE) |
WError | MapPixels (void **const pixels, W_MAP_FLAGS flags) |
void | UnmapPixels () |
VkImageView | GetView () const |
VkImageLayout | GetViewLayout () const |
void | TransitionLayoutTo (VkCommandBuffer cmdBuf, VkImageLayout newLayout) |
VkFormat | GetFormat () const |
uint32_t | GetWidth () const |
uint32_t | GetHeight () const |
uint32_t | GetDepth () const |
uint32_t | GetArraySize () const |
virtual bool | Valid () const override |
size_t | GetPixelSize () const |
virtual WError | SaveToStream (WFile *file, std::ostream &outputStream) override |
virtual WError | LoadFromStream (WFile *file, std::istream &inputStream, std::vector< void * > &args, std::string nameSuffix) override |
![]() | |
WFileAsset (class Wasabi *const app, uint32_t ID=0) | |
virtual WError | LoadFromStream (class WFile *file, std::istream &inputStream, vector< void * > &args, std::string nameSuffix)=0 |
![]() | |
WBase (class Wasabi *const app, uint32_t ID=0) | |
uint32_t | GetID () const |
std::string | GetName () const |
class Wasabi * | GetAppPtr () const |
void | AddReference () |
void | RemoveReference () |
Static Public Member Functions | |
static std::string | _GetTypeName () |
static std::vector< void * > | LoadArgs (W_IMAGE_CREATE_FLAGS flags=W_IMAGE_CREATE_TEXTURE) |
Friends | |
class | WRenderTarget |
class | WImageManager |
class | WFileAsset |
Additional Inherited Members | |
![]() | |
class Wasabi * | m_app |
uint32_t | m_ID |
std::string | m_name |
This class represents an image, or texture, used by Wasabi.
|
static |
Returns "Image" string.
WError WImage::CopyFrom | ( | WImage *const | image, |
W_IMAGE_CREATE_FLAGS | flags = W_IMAGE_CREATE_TEXTURE |
||
) |
Copy another WImage. Only images created with bDynamic == true can be copied.
image | Pointer to the (dynamic) image to copy from |
flags | Image creation flags, see W_IMAGE_CREATE_FLAGS |
WError WImage::CreateFromPixelsArray | ( | void * | pixels, |
uint32_t | width, | ||
uint32_t | height, | ||
uint32_t | depth, | ||
VkFormat | format, | ||
uint32_t | arraySize = 1 , |
||
W_IMAGE_CREATE_FLAGS | flags = W_IMAGE_CREATE_TEXTURE |
||
) |
depth | Depth of the image |
arraySize | Can be used to crteate an array of images |
WError WImage::CreateFromPixelsArray | ( | void * | pixels, |
uint32_t | width, | ||
uint32_t | height, | ||
VkFormat | format, | ||
W_IMAGE_CREATE_FLAGS | flags = W_IMAGE_CREATE_TEXTURE |
||
) |
Creates the image from an array of pixels. The array of pixels need to be in the same format specified, using the same component size and the same number of components.
Examples: A 64x64 image with a 4-component floating-point pixel (R32G32B32A32).
Same as the above example, but using WColor for easier access and more readability.
Creating a 32x32, 2 component UNORM format image.
pixels | A pointer to the memory containing the pixels. If NULL, the image will not have initial data. |
width | Width of the image |
height | Height of the image |
format | Image format |
flags | Image creation flags, see W_IMAGE_CREATE_FLAGS |
uint32_t WImage::GetArraySize | ( | ) | const |
Retrieves the size of the array of images (if used, default is 1).
uint32_t WImage::GetDepth | ( | ) | const |
Retrieves the depth of the image.
VkFormat WImage::GetFormat | ( | ) | const |
Retrieves the Vulkan format used for this image.
uint32_t WImage::GetHeight | ( | ) | const |
Retrieves the height of the image.
size_t WImage::GetPixelSize | ( | ) | const |
Retrieves the size of a pixel in this image.
|
overridevirtual |
This function must be implemented by a child class. This is used for debugging, in which a class should return its name.
Implements WBase.
VkImageView WImage::GetView | ( | ) | const |
Retrieves the Vulkan image view object for this image.
VkImageLayout WImage::GetViewLayout | ( | ) | const |
Retrieves the Vulkan image layout for the image view.
uint32_t WImage::GetWidth | ( | ) | const |
Retrieves the width of the image.
WError WImage::Load | ( | std::string | filename, |
W_IMAGE_CREATE_FLAGS | flags = W_IMAGE_CREATE_TEXTURE |
||
) |
Loads an image from a file. The image format can be any of the formats supported by the stb library (includes .png, .jpg, .tga, .bmp).
filename | Name of the file to load |
flags | Image creation flags, see W_IMAGE_CREATE_FLAGS |
WError WImage::MapPixels | ( | void **const | pixels, |
W_MAP_FLAGS | flags | ||
) |
Maps the pixels of the image for reading or writing. Only images created with bDynamic == true can be mapped.
Examples:
pixels | The address of a pointer to have it point to the mapped memory of the pixels |
flags | Map flags (bitwise OR'd), specifying read/write intention |
|
overridevirtual |
|
overridevirtual |
void WImage::TransitionLayoutTo | ( | VkCommandBuffer | cmdBuf, |
VkImageLayout | newLayout | ||
) |
Transitions the layout of the currently buffered image to the specified layout
cmdBuf | Command buffer to perform the transition in |
newLayout | New Vulkan layout for the underlying image |
void WImage::UnmapPixels | ( | ) |
Unmaps pixels from a previous MapPixels() call. If MapPixels was called with bReadOnly set to false, this will apply the changes to the image.
|
overridevirtual |
Returns true if the image is valid. The image is valid if it has a usable Vulkan image view.
Implements WBase.