#include <texture2d.h>
Public Member Functions | |
Texture2D (Core &core) | |
~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 |
const SurfaceDescriptor & | getDescriptor () const |
void | update (const void *data, int width, int height, int pitch, ESurfaceChannels channels) |
void | update (const void *data, const SurfaceDescriptor &surfaceDescriptor) |
VkFormat | getFormat () const |
const ImageData & | getHandle () const |
int | getMipmapCount () |
RenderService & | getRenderService () |
const RenderService & | getRenderService () const |
void | asyncGetData (Bitmap &bitmap) |
void | asyncGetData (std::function< void(const void *, size_t)> copyFunction) |
VkImageView | getImageView () const |
![]() | |
Resource () | |
![]() | |
Object () | |
virtual | ~Object () |
virtual bool | init (utility::ErrorState &errorState) |
virtual void | onDestroy () |
Object (Object &)=delete | |
Object & | operator= (const Object &)=delete |
Object (Object &&)=delete | |
Object & | operator= (Object &&)=delete |
Public Attributes | |
ETextureUsage | mUsage = ETextureUsage::Static |
Property: 'Usage' If this texture is updated frequently or considered static. More... | |
![]() | |
std::string | mID |
Property: 'mID' unique name of the object. Used as an identifier by the system. More... | |
Protected Attributes | |
RenderService * | mRenderService = nullptr |
Additional Inherited Members | |
![]() | |
static bool | isIDProperty (rtti::Instance &object, const rtti::Property &property) |
GPU representation of a 2D image. This class does not own any CPU data. It offers the user an interface to upload & download texture data, from and to a bitmap. When usage is set to 'Static' (default) or 'DynamicRead' data can be uploaded only once. When usage is set to 'DynamicWrite' the texture be updated frequently from CPU to GPU.
|
override |
void asyncGetData | ( | Bitmap & | bitmap | ) |
Starts a transfer of texture data from GPU to CPU. This is a non blocking call. When the transfer completes, the bitmap will be filled with the texture data.
bitmap | the bitmap to download texture data into. |
void asyncGetData | ( | std::function< void(const void *, size_t)> | copyFunction | ) |
Starts a transfer of texture data from GPU to CPU. Use this overload to pass your own copy function. This is a non blocking call. When the transfer completes, the bitmap will be filled with the texture data.
copyFunction | the copy function to call when the texture data is available for download. |
const SurfaceDescriptor& getDescriptor | ( | ) | const |
VkFormat getFormat | ( | ) | const |
const ImageData& getHandle | ( | ) | const |
int getHeight | ( | ) | const |
VkImageView getImageView | ( | ) | const |
int getMipmapCount | ( | ) |
RenderService& getRenderService | ( | ) |
const RenderService& getRenderService | ( | ) | const |
const glm::vec2 getSize | ( | ) | const |
int getWidth | ( | ) | const |
bool init | ( | const SurfaceDescriptor & | descriptor, |
bool | generateMipMaps, | ||
const glm::vec4 & | clearColor, | ||
VkImageUsageFlags | requiredFlags, | ||
utility::ErrorState & | errorState | ||
) |
Creates the texture on the GPU using the provided settings. The texture is cleared to 'ClearColor'. The Vulkan image usage flags are derived from texture usage.
descriptor | texture description. |
generateMipMaps | if mip maps are generated when data is uploaded. |
clearColor | the color to clear the texture with. |
requiredFlags | image usage flags that are required, 0 = no additional usage flags. |
errorState | contains the error if the texture can't be initialized. |
bool init | ( | const SurfaceDescriptor & | descriptor, |
bool | generateMipMaps, | ||
VkImageUsageFlags | requiredFlags, | ||
utility::ErrorState & | errorState | ||
) |
Creates the texture on the GPU using the provided settings. The texture is cleared to 'ClearColor'. Otherwise the layout of the texture on the GPU will be undefined until upload. The Vulkan image usage flags are derived from texture usage.
descriptor | texture description. |
generateMipMaps | if mip maps are generated when data is uploaded. |
requiredFlags | image usage flags that are required, 0 = no additional usage flags. |
errorState | contains the error if the texture can't be initialized. |
bool init | ( | const SurfaceDescriptor & | descriptor, |
bool | generateMipMaps, | ||
void * | initialData, | ||
VkImageUsageFlags | requiredFlags, | ||
utility::ErrorState & | errorState | ||
) |
Creates the texture on the GPU using the provided settings and immediately requests a content upload. The Vulkan image usage flags are derived from texture usage.
descriptor | texture description. |
generateMipMaps | if mip maps are generated when data is uploaded. |
initialData | the data to upload, must be of size SurfaceDescriptor::getSizeInBytes(). |
requiredFlags | image usage flags that are required, 0 = no additional usage flags |
errorState | contains the error if the texture can't be initialized. |
void update | ( | const void * | data, |
const SurfaceDescriptor & | surfaceDescriptor | ||
) |
Uploads CPU data to the texture on the GPU. Note that you can only update the contents of a texture once if 'Usage' is 'DynamicRead' or 'Static'.
data | pointer to the CPU data. |
surfaceDescriptor | texture description. |
void update | ( | const void * | data, |
int | width, | ||
int | height, | ||
int | pitch, | ||
ESurfaceChannels | channels | ||
) |
Uploads CPU data to the texture on the GPU. Note that you can only update the contents of a texture once if 'Usage' is 'DynamicRead' or 'Static'.
data | pointer to the CPU data. |
width | width of the image in pixels |
height | height of the image in pixels |
pitch | size in bytes of a single row of pixel data. |
channels | total number of channels: 3 for RGB, 4 for RGBA etc. |
|
protected |
ETextureUsage mUsage = ETextureUsage::Static |
Property: 'Usage' If this texture is updated frequently or considered static.