Makes managing textures samplers and off-screen rendering simpler.
More...
#include <vulkan/vulkan.h>
#include "VK2D/Structs.h"
Go to the source code of this file.
|
| VK2DTexture | vk2dTextureLoadFromImage (VK2DImage image) |
| | Creates a texture from an image.
|
| VK2DTexture | vk2dTextureLoad (const char *filename) |
| | Loads a texture from a file (png, bmp, jpg, tiff).
|
| VK2DTexture | vk2dTextureFrom (const void *data, int size) |
| | Same as vk2dTextureLoad but it uses a byte buffer instead of pulling from a file.
|
| VK2DTexture | vk2dTextureCreate (float w, float h) |
| | Creates a texture meant as a drawing target - see vk2dRendererSetTarget.
|
| bool | vk2dTextureUpdate (VK2DTexture tex, const void *pixels) |
| | Replaces all pixels of a texture.
|
| bool | vk2dTextureUpdateRegion (VK2DTexture tex, const void *pixels, int x, int y, int w, int h) |
| | Replaces a rectangle of pixels in a texture.
|
| float | vk2dTextureWidth (VK2DTexture tex) |
| | Gets the width in pixels of a texture.
|
| float | vk2dTextureHeight (VK2DTexture tex) |
| | Gets the height in pixels of a texture.
|
| bool | vk2dTextureIsTarget (VK2DTexture tex) |
| | Checks if a texture was created as a target or not.
|
| VK2DImage | vk2dTextureGetImage (VK2DTexture tex) |
| | Returns a texture's internal image.
|
| uint32_t | vk2dTextureGetID (VK2DTexture tex) |
| | Returns a unique ID for this texture.
|
| void | vk2dTextureFree (VK2DTexture tex) |
| | Frees a texture from memory.
|
| bool | vk2dTextureCopyPixels (VK2DTexture tex, void *outPixels) |
| | Reads a texture's pixels back from the GPU.
|
Makes managing textures samplers and off-screen rendering simpler.
- Author
- Paolo Mazzon
◆ vk2dTextureCopyPixels()
| bool vk2dTextureCopyPixels |
( |
VK2DTexture | tex, |
|
|
void * | outPixels ) |
Reads a texture's pixels back from the GPU.
- Parameters
-
| tex | Texture to read, either loaded or a render target |
| outPixels | Buffer of at least width * height * 4 bytes that receives tightly packed 8-bit RGBA pixels |
- Returns
- Returns true if the pixels were read
- Warning
- Not thread-safe, and waits for the device queue to go idle.
◆ vk2dTextureCreate()
| VK2DTexture vk2dTextureCreate |
( |
float | w, |
|
|
float | h ) |
Creates a texture meant as a drawing target - see vk2dRendererSetTarget.
- Parameters
-
| w | Width of the texture |
| h | Height of the texture |
- Returns
- Returns a new texture or NULL if it failed
- Warning
- If you do not completely fill the created texture (ie, with something like vk2dRendererEmpty or vk2dRendererClear) before you draw this texture it will cause crashes on certain hardware.
◆ vk2dTextureFree()
| void vk2dTextureFree |
( |
VK2DTexture | tex | ) |
|
Frees a texture from memory.
- Parameters
-
◆ vk2dTextureFrom()
| VK2DTexture vk2dTextureFrom |
( |
const void * | data, |
|
|
int | size ) |
Same as vk2dTextureLoad but it uses a byte buffer instead of pulling from a file.
- Parameters
-
| data | Pointer to the image data, either png, bmp, jpg, or tiff |
| size | Size in bytes of the data buffer |
- Returns
- Returns a new texture or NULL if it failed
- Warning
- Textures created with this function are NOT valid render targets
◆ vk2dTextureGetID()
| uint32_t vk2dTextureGetID |
( |
VK2DTexture | tex | ) |
|
Returns a unique ID for this texture.
- Parameters
-
| tex | Texture to get the id of |
- Returns
- Returns a unique uint32_t ID for this texture, used for sprite batching/user shaders
This function is thread-safe.
◆ vk2dTextureGetImage()
| VK2DImage vk2dTextureGetImage |
( |
VK2DTexture | tex | ) |
|
Returns a texture's internal image.
- Parameters
-
- Returns
- Returns the texture's image
◆ vk2dTextureHeight()
| float vk2dTextureHeight |
( |
VK2DTexture | tex | ) |
|
Gets the height in pixels of a texture.
- Parameters
-
| tex | Texture to get the height from |
- Returns
- Returns the height in pixels
◆ vk2dTextureIsTarget()
| bool vk2dTextureIsTarget |
( |
VK2DTexture | tex | ) |
|
Checks if a texture was created as a target or not.
- Parameters
-
- Returns
- Returns true if its a valid target, false otherwise
◆ vk2dTextureLoad()
| VK2DTexture vk2dTextureLoad |
( |
const char * | filename | ) |
|
Loads a texture from a file (png, bmp, jpg, tiff).
- Parameters
-
- Returns
- Returns a new texture or NULL if it failed
- Warning
- Textures created with this function are NOT valid render targets
◆ vk2dTextureLoadFromImage()
| VK2DTexture vk2dTextureLoadFromImage |
( |
VK2DImage | image | ) |
|
Creates a texture from an image.
- Parameters
-
- Returns
- Returns a new texture or NULL if it failed
- Warning
- Textures created with this function are NOT valid render targets
◆ vk2dTextureUpdate()
| bool vk2dTextureUpdate |
( |
VK2DTexture | tex, |
|
|
const void * | pixels ) |
Replaces all pixels of a texture.
- Parameters
-
| tex | Texture loaded from a file, memory or an image; render targets are refused |
| pixels | Tightly packed 8-bit RGBA pixels, width * height * 4 bytes |
- Returns
- Returns true if the pixels were uploaded
- Warning
- Same rules as vk2dImageUpdate: main thread only, waits for the device queue to go idle, and the new pixels apply to every draw of the frame being recorded.
◆ vk2dTextureUpdateRegion()
| bool vk2dTextureUpdateRegion |
( |
VK2DTexture | tex, |
|
|
const void * | pixels, |
|
|
int | x, |
|
|
int | y, |
|
|
int | w, |
|
|
int | h ) |
Replaces a rectangle of pixels in a texture.
- Parameters
-
| tex | Texture loaded from a file, memory or an image; render targets are refused |
| pixels | Tightly packed 8-bit RGBA pixels for the rectangle, w * h * 4 bytes |
| x | Left edge of the rectangle in pixels |
| y | Top edge of the rectangle in pixels |
| w | Width of the rectangle in pixels |
| h | Height of the rectangle in pixels |
- Returns
- Returns true if the pixels were uploaded, false if the texture is a render target or the rectangle does not fit inside it
- Warning
- Same rules as vk2dImageUpdate.
◆ vk2dTextureWidth()
| float vk2dTextureWidth |
( |
VK2DTexture | tex | ) |
|
Gets the width in pixels of a texture.
- Parameters
-
| tex | Texture to get the width from |
- Returns
- Returns the width in pixels