Create typedef for IDs

There was a code, where id for something was u32, and
u16 for other things. I have created a typedef to fix
that

Signed-off-by: Piotr Krygier <piotrkrygier@everyonecancode@xyz>
This commit is contained in:
Piotr Krygier
2026-02-10 10:16:32 +01:00
parent 55e0ee261e
commit 954876549d
13 changed files with 117 additions and 105 deletions
+5 -5
View File
@@ -54,7 +54,7 @@ rse_err_t descriptor_pool_initialize(struct graphics_context_t* context)
return RSE_ERROR_NO_ERROR; return RSE_ERROR_NO_ERROR;
} }
rse_err_t descriptor_create_new_set(struct graphics_context_t* context, uint32_t* set_id) rse_err_t descriptor_create_new_set(struct graphics_context_t* context, rse_id_t* set_id)
{ {
if (context->descriptor_data.descriptor_sets_count >= DESCRIPTOR_MAX_SETS) { if (context->descriptor_data.descriptor_sets_count >= DESCRIPTOR_MAX_SETS) {
SDL_LogCritical(SDL_LOG_CATEGORY_GPU, "Reached maximum number of available descriptor sets"); SDL_LogCritical(SDL_LOG_CATEGORY_GPU, "Reached maximum number of available descriptor sets");
@@ -83,7 +83,7 @@ rse_err_t descriptor_add_layout(struct descriptor_set_layout_bindings_t* layout_
rse_err_t descriptor_set_finish(struct graphics_context_t* context, rse_err_t descriptor_set_finish(struct graphics_context_t* context,
struct descriptor_set_layout_bindings_t* layout_bindings, struct descriptor_set_layout_bindings_t* layout_bindings,
uint32_t set_id) rse_id_t set_id)
{ {
VkDescriptorSetLayoutCreateInfo create_info = {0}; VkDescriptorSetLayoutCreateInfo create_info = {0};
@@ -137,8 +137,8 @@ rse_err_t descriptor_build_sets(struct graphics_context_t* context)
} }
rse_err_t descriptor_attach_images(struct graphics_context_t* context, rse_err_t descriptor_attach_images(struct graphics_context_t* context,
uint32_t descriptor_set_id, rse_id_t descriptor_set_id,
uint16_t* texture_ids, rse_id_t* texture_ids,
size_t images_count, size_t images_count,
VkSampler sampler, VkSampler sampler,
uint32_t binding) uint32_t binding)
@@ -169,7 +169,7 @@ rse_err_t descriptor_attach_images(struct graphics_context_t* context,
} }
rse_err_t descriptor_attach_buffer(struct graphics_context_t* context, rse_err_t descriptor_attach_buffer(struct graphics_context_t* context,
uint32_t descriptor_set_id, rse_id_t descriptor_set_id,
struct vulkan_buffer_t* buffer, struct vulkan_buffer_t* buffer,
uint32_t binding, uint32_t binding,
VkDescriptorType type) VkDescriptorType type)
+6 -5
View File
@@ -24,7 +24,7 @@ rse_err_t descriptor_pool_add_type(struct graphics_context_t* context, VkDescrip
rse_err_t descriptor_pool_initialize(struct graphics_context_t* context); rse_err_t descriptor_pool_initialize(struct graphics_context_t* context);
rse_err_t descriptor_create_new_set(struct graphics_context_t* context, uint32_t* set_id); rse_err_t descriptor_create_new_set(struct graphics_context_t* context, rse_id_t* set_id);
rse_err_t descriptor_add_layout(struct descriptor_set_layout_bindings_t* layout_bindings, rse_err_t descriptor_add_layout(struct descriptor_set_layout_bindings_t* layout_bindings,
uint32_t binding, uint32_t binding,
@@ -34,7 +34,7 @@ rse_err_t descriptor_add_layout(struct descriptor_set_layout_bindings_t* layout_
rse_err_t descriptor_set_finish(struct graphics_context_t* context, rse_err_t descriptor_set_finish(struct graphics_context_t* context,
struct descriptor_set_layout_bindings_t* layout_bindings, struct descriptor_set_layout_bindings_t* layout_bindings,
uint32_t set_id); rse_id_t set_id);
rse_err_t descriptor_build_sets(struct graphics_context_t* context); rse_err_t descriptor_build_sets(struct graphics_context_t* context);
@@ -55,17 +55,18 @@ rse_err_t descriptor_add_set(struct descriptor_set_handle_t* descriptor_set_hand
VkShaderStageFlags shader_stages); VkShaderStageFlags shader_stages);
rse_err_t descriptor_attach_images(struct graphics_context_t* context, rse_err_t descriptor_attach_images(struct graphics_context_t* context,
uint32_t descriptor_set_id, rse_id_t descriptor_set_id,
uint16_t* texture_ids, rse_id_t* texture_ids,
size_t images_count, size_t images_count,
VkSampler sampler, VkSampler sampler,
uint32_t binding); uint32_t binding);
rse_err_t descriptor_attach_buffer(struct graphics_context_t* context, rse_err_t descriptor_attach_buffer(struct graphics_context_t* context,
uint32_t descriptor_set_id, rse_id_t descriptor_set_id,
struct vulkan_buffer_t* buffer, struct vulkan_buffer_t* buffer,
uint32_t binding, uint32_t binding,
VkDescriptorType type); VkDescriptorType type);
void destroy_descriptors(struct graphics_context_t* context); void destroy_descriptors(struct graphics_context_t* context);
#endif // !DESCRIPTOR_BUILDER_H #endif // !DESCRIPTOR_BUILDER_H
+66 -61
View File
@@ -23,12 +23,12 @@
#include "freetype/freetype.h" #include "freetype/freetype.h"
#include "graphics_context.h" #include "graphics_context.h"
#include "mesh_controller.h"
#include "src/vulkan_commons.h" #include "src/vulkan_commons.h"
#include "utilities/file_utils.h"
#include "vulkan_image.h"
#include "utilities/commons.h" #include "utilities/commons.h"
#include "utilities/errors_common.h" #include "utilities/errors_common.h"
#include "mesh_controller.h" #include "utilities/file_utils.h"
#include "vulkan_image.h"
#define FONTS_START_CHARACTER_CODE (33U) #define FONTS_START_CHARACTER_CODE (33U)
@@ -50,7 +50,7 @@ rse_err_t fonts_init(void)
return RSE_ERROR_NO_ERROR; return RSE_ERROR_NO_ERROR;
} }
rse_err_t fonts_load_from_file(struct graphics_context_t* context, const char* file_path, uint32_t* font_id) rse_err_t fonts_load_from_file(struct graphics_context_t* context, const char* file_path, rse_id_t* font_id)
{ {
FT_Error error = FT_Err_Ok; FT_Error error = FT_Err_Ok;
rse_err_t ret = RSE_ERROR_NO_ERROR; rse_err_t ret = RSE_ERROR_NO_ERROR;
@@ -79,7 +79,7 @@ rse_err_t fonts_load_from_file(struct graphics_context_t* context, const char* f
return RSE_ERROR_NO_ERROR; return RSE_ERROR_NO_ERROR;
} }
rse_err_t fonts_set_font_size(struct graphics_context_t* context, const uint32_t font_id, const uint32_t font_size) rse_err_t fonts_set_font_size(struct graphics_context_t* context, const rse_id_t font_id, const uint32_t font_size)
{ {
rse_err_t status = RSE_ERROR_NO_ERROR; rse_err_t status = RSE_ERROR_NO_ERROR;
// size_t iter = 0U; // size_t iter = 0U;
@@ -94,9 +94,7 @@ rse_err_t fonts_set_font_size(struct graphics_context_t* context, const uint32_t
assert(font_id < FONTS_MAX_COUNT); assert(font_id < FONTS_MAX_COUNT);
assert(g_font_faces[font_id] != NULL); assert(g_font_faces[font_id] != NULL);
error = FT_Set_Pixel_Sizes(g_font_faces[font_id], error = FT_Set_Pixel_Sizes(g_font_faces[font_id], 0, font_size);
0,
font_size);
if (error != FT_Err_Ok) { if (error != FT_Err_Ok) {
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Failed to set font size. Error code: %d", error); SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Failed to set font size. Error code: %d", error);
@@ -107,75 +105,81 @@ rse_err_t fonts_set_font_size(struct graphics_context_t* context, const uint32_t
font->font_size = font_size; font->font_size = font_size;
// for (iter = 0U; iter < FONT_CHARACTERS_COUNT; ++iter) { // for (iter = 0U; iter < FONT_CHARACTERS_COUNT; ++iter) {
// glyph_index = iter + FONTS_START_CHARACTER_CODE; // glyph_index = iter + FONTS_START_CHARACTER_CODE;
glyph_index = 33 + FONTS_START_CHARACTER_CODE; glyph_index = 33 + FONTS_START_CHARACTER_CODE;
error = FT_Load_Char(g_font_faces[font_id], glyph_index, FT_LOAD_RENDER); error = FT_Load_Char(g_font_faces[font_id], glyph_index, FT_LOAD_RENDER);
if (error != FT_Err_Ok) { if (error != FT_Err_Ok) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"Failed to load glyph with id %d. Error code: %d", "Failed to load glyph with id %d. Error code: %d",
glyph_index, glyph_index,
error); error);
// continue; // continue;
return RSE_ERROR_INTERNAL_ERROR; return RSE_ERROR_INTERNAL_ERROR;
} }
glyph = g_font_faces[font_id]->glyph; glyph = g_font_faces[font_id]->glyph;
STATUS_CHECK(load_texture_from_bitmat(context, STATUS_CHECK(load_texture_from_bitmat(context,
glyph->bitmap.buffer, glyph->bitmap.buffer,
glyph->bitmap.width, glyph->bitmap.width,
glyph->bitmap.rows, glyph->bitmap.rows,
&font->font_characters[33].texture_id, &font->font_characters[33].texture_id,
VK_FORMAT_R8_UNORM)); VK_FORMAT_R8_UNORM));
vertices[0].pos[0] = 0.0 - glyph->bitmap.width; vertices[0].pos[0] = 0.0 - glyph->bitmap.width;
vertices[0].pos[1] = glyph->bitmap.rows; vertices[0].pos[1] = glyph->bitmap.rows;
vertices[0].pos[2] = 0.0; vertices[0].pos[2] = 0.0;
vertices[0].color[0] = 1.0; vertices[0].color[0] = 1.0;
vertices[0].color[1] = 1.0; vertices[0].color[1] = 1.0;
vertices[0].color[2] = 1.0; vertices[0].color[2] = 1.0;
vertices[0].tex_coords[0] = 0.0; vertices[0].tex_coords[0] = 0.0;
vertices[0].tex_coords[1] = 1.0; vertices[0].tex_coords[1] = 1.0;
vertices[1].pos[0] = glyph->bitmap.width; vertices[1].pos[0] = glyph->bitmap.width;
vertices[1].pos[1] = glyph->bitmap.rows; vertices[1].pos[1] = glyph->bitmap.rows;
vertices[1].pos[2] = 0.0; vertices[1].pos[2] = 0.0;
vertices[1].color[0] = 1.0; vertices[1].color[0] = 1.0;
vertices[1].color[1] = 1.0; vertices[1].color[1] = 1.0;
vertices[1].color[2] = 1.0; vertices[1].color[2] = 1.0;
vertices[1].tex_coords[0] = 1.0; vertices[1].tex_coords[0] = 1.0;
vertices[1].tex_coords[1] = 1.0; vertices[1].tex_coords[1] = 1.0;
vertices[2].pos[0] = glyph->bitmap.width; vertices[2].pos[0] = glyph->bitmap.width;
vertices[2].pos[1] = 0.0 - glyph->bitmap.rows; vertices[2].pos[1] = 0.0 - glyph->bitmap.rows;
vertices[2].pos[2] = 0.0; vertices[2].pos[2] = 0.0;
vertices[2].color[0] = 1.0; vertices[2].color[0] = 1.0;
vertices[2].color[1] = 1.0; vertices[2].color[1] = 1.0;
vertices[2].color[2] = 1.0; vertices[2].color[2] = 1.0;
vertices[2].tex_coords[0] = 1.0; vertices[2].tex_coords[0] = 1.0;
vertices[2].tex_coords[1] = 0.0; vertices[2].tex_coords[1] = 0.0;
vertices[3].pos[0] = 0.0 - glyph->bitmap.width; vertices[3].pos[0] = 0.0 - glyph->bitmap.width;
vertices[3].pos[1] = 0.0 - glyph->bitmap.rows; vertices[3].pos[1] = 0.0 - glyph->bitmap.rows;
vertices[3].pos[2] = 0.0; vertices[3].pos[2] = 0.0;
vertices[3].color[0] = 1.0; vertices[3].color[0] = 1.0;
vertices[3].color[1] = 1.0; vertices[3].color[1] = 1.0;
vertices[3].color[2] = 1.0; vertices[3].color[2] = 1.0;
vertices[3].tex_coords[0] = 0.0; vertices[3].tex_coords[0] = 0.0;
vertices[3].tex_coords[1] = 0.0; vertices[3].tex_coords[1] = 0.0;
STATUS_CHECK(mesh_create(context, vertices, indices, 4, 6, &font->font_characters[33].mesh_id)); STATUS_CHECK(mesh_create(context, vertices, indices, 4, 6, &font->font_characters[33].mesh_id));
// } // }
return RSE_ERROR_NO_ERROR; return RSE_ERROR_NO_ERROR;
} }
rse_err_t print_debug_text(struct graphics_context_t* context, uint32_t font_id, char *text) rse_err_t print_debug_text(struct graphics_context_t* context, rse_id_t font_id, char* text)
{ {
rse_err_t status = RSE_ERROR_NO_ERROR; rse_err_t status = RSE_ERROR_NO_ERROR;
(void)text; (void)text;
STATUS_CHECK(mesh_create_instance(context, context->fonts_data.fonts[font_id].font_characters[33].mesh_id, (struct instance_data_t){{0.0f, 0.0f, 2.4f}, {0.0f, 0.0f, 0.0}, 1.0f, context->fonts_data.fonts[font_id].font_characters[33].texture_id})); STATUS_CHECK(mesh_create_instance(
context,
context->fonts_data.fonts[font_id].font_characters[33].mesh_id,
(struct instance_data_t){{0.0f, 0.0f, 2.4f},
{0.0f, 0.0f, 0.0},
1.0f,
context->fonts_data.fonts[font_id].font_characters[33].texture_id}));
return status; return status;
} }
@@ -218,7 +222,8 @@ rse_err_t print_debug_text(struct graphics_context_t* context, uint32_t font_id,
// } // }
// } // }
// //
// STATUS_CHECK(texture_update_image(context, (unsigned char*)context->debug_overlay.pixels, width, height, context->debug_overlay.texture_id, VK_FORMAT_R8G8B8A8_UNORM)); // STATUS_CHECK(texture_update_image(context, (unsigned char*)context->debug_overlay.pixels, width, height,
// context->debug_overlay.texture_id, VK_FORMAT_R8G8B8A8_UNORM));
// //
// return RSE_ERROR_NO_ERROR; // return RSE_ERROR_NO_ERROR;
// } // }
+3 -3
View File
@@ -16,8 +16,8 @@
#include "graphics_context.h" #include "graphics_context.h"
rse_err_t fonts_init(void); rse_err_t fonts_init(void);
rse_err_t fonts_load_from_file(struct graphics_context_t* context, const char* file_path, uint32_t* font_id); rse_err_t fonts_load_from_file(struct graphics_context_t* context, const char* file_path, rse_id_t* font_id);
rse_err_t fonts_set_font_size(struct graphics_context_t* context, const uint32_t font_id, const uint32_t font_size); rse_err_t fonts_set_font_size(struct graphics_context_t* context, const rse_id_t font_id, const uint32_t font_size);
rse_err_t print_debug_text(struct graphics_context_t* context, uint32_t font_id, char *text); rse_err_t print_debug_text(struct graphics_context_t* context, rse_id_t font_id, char *text);
#endif /* FONT_MANAGER_H */ #endif /* FONT_MANAGER_H */
+5 -5
View File
@@ -165,7 +165,7 @@ struct pipeline_t
struct pipeline_internal_t struct pipeline_internal_t
{ {
uint32_t descriptor_set_ids[MAX_PIPELINE_COUNT]; rse_id_t descriptor_set_ids[MAX_PIPELINE_COUNT];
size_t pipelines_count; size_t pipelines_count;
size_t pipeline_layouts_count; size_t pipeline_layouts_count;
VkPipeline pipelines[MAX_PIPELINE_COUNT]; VkPipeline pipelines[MAX_PIPELINE_COUNT];
@@ -234,14 +234,14 @@ struct mesh_data_t {
struct debug_overlay_t struct debug_overlay_t
{ {
uint16_t texture_id; rse_id_t texture_id;
uint32_t* pixels; uint32_t* pixels;
size_t pixels_size; size_t pixels_size;
struct vulkan_image_t image_handle; struct vulkan_image_t image_handle;
VkSampler sampler; VkSampler sampler;
}; };
typedef rse_err_t(*renderer_function_t)(struct graphics_context_t* context, uint32_t renderer_id); typedef rse_err_t(*renderer_function_t)(struct graphics_context_t* context, rse_id_t renderer_id);
struct renderer_t { struct renderer_t {
renderer_function_t render_function; renderer_function_t render_function;
@@ -253,8 +253,8 @@ struct renderer_data_t {
}; };
struct font_character_data_t { struct font_character_data_t {
uint32_t mesh_id; rse_id_t mesh_id;
uint16_t texture_id; rse_id_t texture_id;
}; };
struct sized_font_data_t { struct sized_font_data_t {
+1 -1
View File
@@ -24,7 +24,7 @@ rse_err_t mesh_create(struct graphics_context_t* context,
uint16_t* indices, uint16_t* indices,
size_t vertices_count, size_t vertices_count,
size_t indices_count, size_t indices_count,
uint32_t* mesh_id) rse_id_t* mesh_id)
{ {
rse_err_t status = RSE_ERROR_NO_ERROR; rse_err_t status = RSE_ERROR_NO_ERROR;
+5 -5
View File
@@ -29,7 +29,7 @@
rse_err_t mesh_create(struct graphics_context_t* context, struct vertex_t* vertices, rse_err_t mesh_create(struct graphics_context_t* context, struct vertex_t* vertices,
uint16_t* indices, uint16_t* indices,
size_t vertices_count, size_t vertices_count,
size_t indices_count, uint32_t* mesh_id); size_t indices_count, rse_id_t* mesh_id);
/** /**
* @brief Create a instance for the selected mesh. Instance can have its own location, rotation and scale * @brief Create a instance for the selected mesh. Instance can have its own location, rotation and scale
@@ -47,15 +47,15 @@ rse_err_t mesh_create_instance(struct graphics_context_t* context, entity_t enti
* @param mesh_id Mesh identifier * @param mesh_id Mesh identifier
* @return size_t Number of vertices * @return size_t Number of vertices
*/ */
size_t get_vertices_count(struct graphics_context_t* context, uint16_t mesh_id); // size_t get_vertices_count(struct graphics_context_t* context, rse_id_t mesh_id);
/** /**
* @brief Get the index count for mesh with mesh_id ID * @brief Get the index count for mesh with mesh_id ID
* *
* @param mesh_id Mesh identifier w @param mesh_id Mesh identifier
* @return size_t Number of indices * @return size_t Number of indices
*/ */
size_t get_indices_count(struct graphics_context_t* context, uint16_t mesh_id); // size_t get_indices_count(struct graphics_context_t* context, rse_id_t mesh_id);
/** /**
* @brief Get vertex offset in vertex buffer for selected mesh * @brief Get vertex offset in vertex buffer for selected mesh
@@ -63,6 +63,6 @@ size_t get_indices_count(struct graphics_context_t* context, uint16_t mesh_id);
* @param mesh_id Mesh identifies * @param mesh_id Mesh identifies
* @return size_t Offset * @return size_t Offset
*/ */
size_t get_vertex_offset(struct graphics_context_t* context, uint16_t mesh_id); // size_t get_vertex_offset(struct graphics_context_t* context, rse_id_t mesh_id);
#endif /* MESH_CONTROLLER_H */ #endif /* MESH_CONTROLLER_H */
+3 -3
View File
@@ -25,7 +25,7 @@
#define MAX_BINDLESS_RESOURCES 1000 #define MAX_BINDLESS_RESOURCES 1000
rse_err_t shader_create_module(struct graphics_context_t* context, rse_err_t shader_create_module(struct graphics_context_t* context,
uint16_t* shader_module_id, rse_id_t* shader_module_id,
const char* shader_path, const char* shader_path,
const VkShaderStageFlagBits shader_stage) const VkShaderStageFlagBits shader_stage)
{ {
@@ -197,7 +197,7 @@ static rse_err_t pipeline_add_depth_stencil(struct pipeline_t* pipeline)
rse_err_t pipeline_add_descriptor_sets(struct graphics_context_t* context, rse_err_t pipeline_add_descriptor_sets(struct graphics_context_t* context,
struct pipeline_t* pipeline, struct pipeline_t* pipeline,
uint32_t descriptor_set_id) rse_id_t descriptor_set_id)
{ {
VkPipelineLayoutCreateInfo create_info = {0}; VkPipelineLayoutCreateInfo create_info = {0};
create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
@@ -271,7 +271,7 @@ rse_err_t pipeline_builder_init(struct pipeline_t* pipeline)
rse_err_t pipeline_add_shader_stage(struct graphics_context_t* context, rse_err_t pipeline_add_shader_stage(struct graphics_context_t* context,
struct pipeline_t* pipeline, struct pipeline_t* pipeline,
const uint32_t shader_id) const rse_id_t shader_id)
{ {
size_t i = 0; size_t i = 0;
rse_err_t status = RSE_ERROR_NO_ERROR; rse_err_t status = RSE_ERROR_NO_ERROR;
+2 -2
View File
@@ -20,7 +20,7 @@
#include "utilities/commons.h" #include "utilities/commons.h"
rse_err_t shader_create_module(struct graphics_context_t* context, rse_err_t shader_create_module(struct graphics_context_t* context,
uint16_t* shader_module_id, rse_id_t* shader_module_id,
const char* shader_path, const char* shader_path,
const VkShaderStageFlagBits shader_stage); const VkShaderStageFlagBits shader_stage);
@@ -42,7 +42,7 @@ rse_err_t pipeline_builder_init(struct pipeline_t* pipeline);
*/ */
rse_err_t pipeline_add_shader_stage(struct graphics_context_t* context, rse_err_t pipeline_add_shader_stage(struct graphics_context_t* context,
struct pipeline_t* pipeline, struct pipeline_t* pipeline,
const uint32_t shader_id); const rse_id_t shader_id);
/** /**
* @brief Add vertex input binding to pipeline * @brief Add vertex input binding to pipeline
+6 -6
View File
@@ -114,16 +114,16 @@ rse_err_t rse_graphics_test_function(struct rse_graphics_context_t* rse_context)
{ {
rse_err_t status = RSE_ERROR_NO_ERROR; rse_err_t status = RSE_ERROR_NO_ERROR;
struct graphics_context_t* context = rse_context->context; struct graphics_context_t* context = rse_context->context;
uint16_t textures[2] = {0}; rse_id_t textures[2] = {0};
struct pipeline_t pipeline; struct pipeline_t pipeline;
uint32_t descriptor_set_handle = 0; rse_id_t descriptor_set_handle = 0;
struct descriptor_set_layout_bindings_t layout_bindings = {0}; struct descriptor_set_layout_bindings_t layout_bindings = {0};
struct pipeline_infos_t pipeline_infos = {0}; struct pipeline_infos_t pipeline_infos = {0};
struct vulkan_buffer_t model_view_projection_buffer = {0}; struct vulkan_buffer_t model_view_projection_buffer = {0};
uint32_t mesh_id_1, mesh_id_2 = 0; rse_id_t mesh_id_1, mesh_id_2 = 0;
uint32_t font_id = 0; rse_id_t font_id = 0;
uint32_t static_mesh_renderer = 0U; rse_id_t static_mesh_renderer = 0U;
uint16_t vertex_shader_id, fragment_shader_id; rse_id_t vertex_shader_id, fragment_shader_id;
texture_load_from_file(context, "../../test_image.jpg", &textures[0]); texture_load_from_file(context, "../../test_image.jpg", &textures[0]);
texture_load_from_file(context, "../../test_image_2.jpg", &textures[1]); texture_load_from_file(context, "../../test_image_2.jpg", &textures[1]);
+5 -5
View File
@@ -304,7 +304,7 @@ static rse_err_t create_textured_image(struct graphics_context_t* context,
uint32_t height, uint32_t height,
VkFormat format, VkFormat format,
const unsigned char* pixels, const unsigned char* pixels,
uint16_t* texture_id) rse_id_t* texture_id)
{ {
rse_err_t status = RSE_ERROR_NO_ERROR; rse_err_t status = RSE_ERROR_NO_ERROR;
struct vulkan_buffer_t staging_buffer = {0}; struct vulkan_buffer_t staging_buffer = {0};
@@ -411,7 +411,7 @@ rse_err_t texture_update_image(struct graphics_context_t* context,
const unsigned char* pixels, const unsigned char* pixels,
int width, int width,
int height, int height,
uint16_t texture_id, rse_id_t texture_id,
VkFormat format) VkFormat format)
{ {
rse_err_t status = RSE_ERROR_NO_ERROR; rse_err_t status = RSE_ERROR_NO_ERROR;
@@ -479,7 +479,7 @@ rse_err_t load_texture_from_bitmat(struct graphics_context_t* context,
const unsigned char* pixel_buffer, const unsigned char* pixel_buffer,
int width, int width,
int height, int height,
uint16_t* texture_id, rse_id_t* texture_id,
VkFormat color_format) VkFormat color_format)
{ {
rse_err_t status = RSE_ERROR_NO_ERROR; rse_err_t status = RSE_ERROR_NO_ERROR;
@@ -490,7 +490,7 @@ rse_err_t load_texture_from_bitmat(struct graphics_context_t* context,
return status; return status;
} }
rse_err_t texture_load_from_file(struct graphics_context_t* context, const char* file_path, uint16_t* texture_id) rse_err_t texture_load_from_file(struct graphics_context_t* context, const char* file_path, rse_id_t* texture_id)
{ {
rse_err_t status = RSE_ERROR_NO_ERROR; rse_err_t status = RSE_ERROR_NO_ERROR;
int width = 0; int width = 0;
@@ -548,7 +548,7 @@ void destroy_color_resource(struct graphics_context_t* context)
vmaDestroyImage(context->vulkan_handles.allocator, context->color_image.image, context->color_image.allocation); vmaDestroyImage(context->vulkan_handles.allocator, context->color_image.image, context->color_image.allocation);
} }
uint8_t image_exists(struct graphics_context_t* context, uint8_t image_id) uint8_t image_exists(struct graphics_context_t* context, rse_id_t image_id)
{ {
return context->texture_images[image_id].id_taken == IMAGE_TAKEN; return context->texture_images[image_id].id_taken == IMAGE_TAKEN;
} }
+4 -4
View File
@@ -38,7 +38,7 @@ rse_err_t init_vulkan_images(struct graphics_context_t* context);
* @return rse_err_t RSE_ERROR_NO_ERROR on success * @return rse_err_t RSE_ERROR_NO_ERROR on success
*/ */
rse_err_t load_texture_from_bitmat(struct graphics_context_t* context, const unsigned char* pixel_buffer, int width, rse_err_t load_texture_from_bitmat(struct graphics_context_t* context, const unsigned char* pixel_buffer, int width,
int height, uint16_t* texture_id, VkFormat color_format); int height, rse_id_t* texture_id, VkFormat color_format);
/** /**
* @brief Loads image from file, for later to be used as a texture * @brief Loads image from file, for later to be used as a texture
@@ -48,13 +48,13 @@ rse_err_t load_texture_from_bitmat(struct graphics_context_t* context, const uns
* @param texture_id Texture ID will be set up here * @param texture_id Texture ID will be set up here
* @return rse_err_t RSE_ERROR_NO_ERROR on success * @return rse_err_t RSE_ERROR_NO_ERROR on success
*/ */
rse_err_t texture_load_from_file(struct graphics_context_t* context, const char* file_path, uint16_t* texture_id); rse_err_t texture_load_from_file(struct graphics_context_t* context, const char* file_path, rse_id_t* texture_id);
rse_err_t texture_update_image(struct graphics_context_t* context, rse_err_t texture_update_image(struct graphics_context_t* context,
const unsigned char* pixels, const unsigned char* pixels,
int width, int width,
int height, int height,
uint16_t texture_id, rse_id_t texture_id,
VkFormat format); VkFormat format);
/** /**
@@ -72,7 +72,7 @@ void destroy_textures(struct graphics_context_t* context);
* @param image_id Image ID * @param image_id Image ID
* @return uint8_t 1 on success, 0 on failure * @return uint8_t 1 on success, 0 on failure
*/ */
uint8_t image_exists(struct graphics_context_t* context, uint8_t image_id); uint8_t image_exists(struct graphics_context_t* context, rse_id_t image_id);
/** /**
* @brief Returns number of loaded texture * @brief Returns number of loaded texture
+6
View File
@@ -45,4 +45,10 @@
*/ */
typedef uint32_t rse_err_t; typedef uint32_t rse_err_t;
/**
* @brief General type for ID use
*
*/
typedef uint32_t rse_id_t;
#endif /* COMMONS_H */ #endif /* COMMONS_H */