[WIP] Add text rendering
This commit is contained in:
1 parent
3bd14b20c2
commit
b2508ce4ff
15 files changed
+248
-27
No files matched your search
@@ -242,6 +242,10 @@ static rse_err_t format_to_pixel_size(VkFormat format,
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case VK_FORMAT_R8_SRGB:
|
||||
case VK_FORMAT_R8_UNORM:
|
||||
*format_size = 1;
|
||||
break;
|
||||
case VK_FORMAT_R8G8B8A8_SRGB:
|
||||
*format_size = 4;
|
||||
break;
|
||||
@@ -258,7 +262,7 @@ static rse_err_t format_to_pixel_size(VkFormat format,
|
||||
static rse_err_t create_textured_image(uint32_t width,
|
||||
uint32_t height,
|
||||
VkFormat format,
|
||||
unsigned char* pixels,
|
||||
const unsigned char* pixels,
|
||||
uint16_t* texture_id)
|
||||
{
|
||||
rse_err_t status = RSE_ERROR_NO_ERROR;
|
||||
@@ -403,7 +407,20 @@ rse_err_t init_vulkan_images()
|
||||
return status;
|
||||
}
|
||||
|
||||
rse_err_t rse_load_texture(const char* file_path, uint16_t* texture_id)
|
||||
rse_err_t rse_load_texture_from_bitmat(const unsigned char* pixel_buffer, int width, int height, uint16_t* texture_id, VkFormat color_format)
|
||||
{
|
||||
rse_err_t status = RSE_ERROR_NO_ERROR;
|
||||
|
||||
/* Create actual Vulkan Image */
|
||||
STATUS_CHECK(create_textured_image(width,
|
||||
height,
|
||||
color_format,
|
||||
pixel_buffer, texture_id));
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
rse_err_t rse_load_texture_from_file(const char* file_path, uint16_t* texture_id)
|
||||
{
|
||||
rse_err_t status = RSE_ERROR_NO_ERROR;
|
||||
int width = 0;
|
||||
@@ -418,16 +435,11 @@ rse_err_t rse_load_texture(const char* file_path, uint16_t* texture_id)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Create actual Vulkan Image */
|
||||
status = create_textured_image(width,
|
||||
height,
|
||||
VK_FORMAT_R8G8B8A8_SRGB,
|
||||
pixel_buffer, texture_id);
|
||||
STATUS_CHECK(rse_load_texture_from_bitmat(pixel_buffer, width, height, texture_id, VK_FORMAT_R8G8B8A8_SRGB));
|
||||
|
||||
stbi_image_free(pixel_buffer);
|
||||
|
||||
return status;
|
||||
|
||||
}
|
||||
|
||||
void rse_destroy_textures()
|
||||
|
||||
Reference in new issue
Block a user