-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathTexture.h
72 lines (60 loc) · 2.78 KB
/
Texture.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/// \file Texture.h
/// \author Paolo Mazzon
/// \brief Makes managing textures samplers and off-screen rendering simpler
#pragma once
#include <vulkan/vulkan.h>
#include "VK2D/Structs.h"
#ifdef __cplusplus
extern "C" {
#endif
/// \brief Creates a texture from an image
/// \param image Image to use
/// \return Returns a new texture or NULL if it failed
/// \warning Textures created with this function are NOT valid render targets
VK2DTexture vk2dTextureLoadFromImage(VK2DImage image);
/// \brief Loads a texture from a file (png, bmp, jpg, tiff)
/// \param filename File to load
/// \return Returns a new texture or NULL if it failed
/// \warning Textures created with this function are NOT valid render targets
VK2DTexture vk2dTextureLoad(const char *filename);
/// \brief Same as vk2dTextureLoad but it uses a byte buffer instead of pulling from a file
/// \param data Pointer to the image data, either png, bmp, jpg, or tiff
/// \param size Size in bytes of the data buffer
/// \return Returns a new texture or NULL if it failed
/// \warning Textures created with this function are NOT valid render targets
VK2DTexture vk2dTextureFrom(void *data, int size);
/// \brief Creates a texture meant as a drawing target - see `vk2dRendererSetTarget`
/// \param w Width of the texture
/// \param h Height of the texture
/// \return 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.
VK2DTexture vk2dTextureCreate(float w, float h);
/// \brief Gets the width in pixels of a texture
/// \param tex Texture to get the width from
/// \return Returns the width in pixels
float vk2dTextureWidth(VK2DTexture tex);
/// \brief Gets the height in pixels of a texture
/// \param tex Texture to get the height from
/// \return Returns the height in pixels
float vk2dTextureHeight(VK2DTexture tex);
/// \brief Checks if a texture was created as a target or not
/// \param tex Texture to check
/// \return Returns true if its a valid target, false otherwise
bool vk2dTextureIsTarget(VK2DTexture tex);
/// \brief Returns a texture's internal image
/// \param tex Texture to check
/// \return Returns the texture's image
VK2DImage vk2dTextureGetImage(VK2DTexture tex);
/// \brief Returns a unique ID for this texture
/// \param tex Texture to get the id of
/// \return Returns a unique uint32_t ID for this texture, used for sprite batching/user shaders
///
/// This function is thread-safe.
uint32_t vk2dTextureGetID(VK2DTexture tex);
/// \brief Frees a texture from memory
/// \param tex Texture to free
void vk2dTextureFree(VK2DTexture tex);
#ifdef __cplusplus
};
#endif