[WIP] Try to enable alpha blending
This commit is contained in:
1 parent
fb3151c5d1
commit
c9384eb795
8 files changed
+41
-26
No files matched your search
+10
-10
@@ -44,18 +44,18 @@ void rse_graphics_test_function(void)
|
||||
return;
|
||||
}
|
||||
rse_fonts_initialize();
|
||||
rse_fonts_load_from_file("/usr/share/fonts/TTF/JetBrainsMonoNerdFont-Medium.ttf");
|
||||
rse_fonts_load_from_file("/usr/share/fonts/JetBrainsMonoNerdFont/JetBrainsMonoNerdFont-Medium.ttf");
|
||||
|
||||
// FIXME: Temporary array of vertices, for testing purposes
|
||||
struct rse_vertex_t vertices[] = {{{-0.5f, -0.5f, 0.0f}, {1.0f, 0.0f, 0.0f}, {0.0f, 0.0f}},
|
||||
{{0.5f, -0.5f, 0.0f}, {0.0f, 1.0f, 0.0f}, {1.0f, 0.0f}},
|
||||
{{0.5f, 0.5f, 0.0f}, {0.0f, 0.0f, 1.0f}, {1.0f, 1.0f}},
|
||||
{{-0.5f, 0.5f, 0.0f}, {1.0f, 1.0f, 1.0f}, {0.0f, 1.0f}}};
|
||||
struct rse_vertex_t vertices[] = {{{-0.5f, -0.5f, 0.0f}, {1.0f, 0.0f, 0.0f, 1.0f}, {0.0f, 0.0f}},
|
||||
{{0.5f, -0.5f, 0.0f}, {0.0f, 1.0f, 0.0f, 1.0f}, {1.0f, 0.0f}},
|
||||
{{0.5f, 0.5f, 0.0f}, {0.0f, 0.0f, 1.0f, 1.0f}, {1.0f, 1.0f}},
|
||||
{{-0.5f, 0.5f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 1.0f}}};
|
||||
|
||||
struct rse_vertex_t vertices2[] = {{{-0.5f, -0.5f, -0.5f}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}},
|
||||
{{0.5f, -0.5f, -0.5f}, {1.0f, 1.0f, 1.0f}, {1.0f, 0.0f}},
|
||||
{{0.5f, 0.5f, -0.5f}, {1.0f, 1.0f, 1.0f}, {1.0f, 1.0f}},
|
||||
{{-0.5f, 0.5f, -0.5f}, {1.0f, 1.0f, 1.0f}, {0.0f, 1.0f}}};
|
||||
struct rse_vertex_t vertices2[] = {{{-0.5f, -0.5f, -0.5f}, {1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}},
|
||||
{{0.5f, -0.5f, -0.5f}, {1.0f, 1.0f, 1.0f, 1.0f}, {1.0f, 0.0f}},
|
||||
{{0.5f, 0.5f, -0.5f}, {1.0f, 1.0f, 1.0f, 1.0f}, {1.0f, 1.0f}},
|
||||
{{-0.5f, 0.5f, -0.5f}, {1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 1.0f}}};
|
||||
|
||||
// FIXME: Temporary array of vertices, for testing purposes
|
||||
uint16_t indices[] = {0, 1, 2, 2, 3, 0};
|
||||
@@ -83,7 +83,7 @@ void rse_graphics_test_function(void)
|
||||
tex_id_2
|
||||
});
|
||||
|
||||
rse_print_text("Hello World!", (struct vec3_t){-1.0f, 1.0f, 0.0f}, 0.3f);
|
||||
rse_print_text("Hello World!", (struct vec3_t){-1.0f, 0.0f, 0.0f}, 0.3f);
|
||||
}
|
||||
|
||||
rse_err_t rse_graphics_run(void)
|
||||
|
||||
+12
-1
@@ -22,6 +22,17 @@ struct vec3_t {
|
||||
float z;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief 4 points vector, useful for colors with alpha channel
|
||||
*
|
||||
*/
|
||||
struct vec4_t {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float w;
|
||||
};
|
||||
|
||||
/* 4x4 matrix.
|
||||
* [x_1 | x_2 | x_3 | x_4]
|
||||
* [y_1 | y_2 | y_3 | y_4]
|
||||
@@ -119,4 +130,4 @@ struct mat4_t rse_math_perspective(float fovy_rad, float aspect_ratio, float z_n
|
||||
*/
|
||||
struct mat4_t rse_math_rotate(struct mat4_t matrix, float radians, struct vec3_t rotation_vector);
|
||||
|
||||
#endif /* RSE_MATH_H */
|
||||
#endif /* RSE_MATH_H */
|
||||
@@ -98,16 +98,16 @@ rse_err_t rse_fonts_load_from_file(const char* file_path)
|
||||
}
|
||||
|
||||
font_vertices[0] = (struct rse_vertex_t) {
|
||||
{g_fonts_data[iter].bearing_x, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}
|
||||
{g_fonts_data[iter].bearing_x, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}
|
||||
};
|
||||
font_vertices[1] = (struct rse_vertex_t) {
|
||||
{g_fonts_data[iter].bearing_x + g_fonts_data[iter].width, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f}, {1.0f, 0.0f}
|
||||
{g_fonts_data[iter].bearing_x + g_fonts_data[iter].width, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}, {1.0f, 0.0f}
|
||||
};
|
||||
font_vertices[2] = (struct rse_vertex_t) {
|
||||
{g_fonts_data[iter].bearing_x + g_fonts_data[iter].width, g_fonts_data[iter].height, 0.0f}, {1.0f, 1.0f, 1.0f}, {1.0f, 1.0f}
|
||||
{g_fonts_data[iter].bearing_x + g_fonts_data[iter].width, g_fonts_data[iter].height, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}, {1.0f, 1.0f}
|
||||
};
|
||||
font_vertices[3] = (struct rse_vertex_t) {
|
||||
{g_fonts_data[iter].bearing_x, g_fonts_data[iter].height, 0.0f}, {1.0f, 1.0f, 1.0f}, {0.0f, 1.0f}
|
||||
{g_fonts_data[iter].bearing_x, g_fonts_data[iter].height, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 1.0f}
|
||||
};
|
||||
|
||||
g_fonts_data[iter].mesh_id = create_mesh(font_vertices, font_indices, 8, 6);
|
||||
@@ -139,7 +139,7 @@ rse_err_t rse_print_text(const char* text, struct vec3_t position, float font_si
|
||||
charactet_code = (size_t)text[iter] - FONT_START_CHARACTER;
|
||||
|
||||
x_pos = position.x + advance - (g_fonts_data[charactet_code].bearing_x * scale);
|
||||
y_pos = position.y - (g_fonts_data[charactet_code].bearing_y * scale);
|
||||
y_pos = position.y - (g_fonts_data[charactet_code].bearing_y * scale);
|
||||
create_mesh_instance(g_fonts_data[charactet_code].mesh_id, (struct rse_instance_data_t){
|
||||
{x_pos, y_pos, 0.0f},
|
||||
{0.0f, 0.0f, rse_math_deg_to_radians(0.0f)},
|
||||
|
||||
@@ -259,7 +259,7 @@ rse_err_t rse_add_vertices(uint16_t mesh_id,
|
||||
index_data->buffer_offset = index_buffer->allocated_size;
|
||||
index_buffer->allocated_size += indices_size;
|
||||
|
||||
vmaDestroyBuffer(g_vulkan_state.allocator, staging_buffer.buffer, staging_buffer.allocation);
|
||||
destroy_buffer(&staging_buffer);
|
||||
|
||||
draw_indirect_command.indexCount = vertex_data->count;
|
||||
draw_indirect_command.instanceCount = 0;
|
||||
@@ -295,7 +295,7 @@ rse_err_t update_mesh_instances(uint16_t mesh_id, struct rse_instance_data_t* in
|
||||
instance_size,
|
||||
instance_buffer->allocated_size);
|
||||
|
||||
vmaDestroyBuffer(g_vulkan_state.allocator, staging_buffer.buffer, staging_buffer.allocation);
|
||||
destroy_buffer(&staging_buffer);
|
||||
|
||||
instance_buffer->allocated_size += instance_size;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ extern struct rse_vulkan_state_t g_vulkan_state;
|
||||
struct rse_vertex_t
|
||||
{
|
||||
struct vec3_t pos;
|
||||
struct vec3_t color;
|
||||
struct vec4_t color;
|
||||
struct vec3_t tex_coords;
|
||||
};
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ static VkVertexInputAttributeDescription* get_attribute_descriptions()
|
||||
|
||||
attribute_descriptions[1].binding = 0;
|
||||
attribute_descriptions[1].location = 1; /* inColor in shader.vert */
|
||||
attribute_descriptions[1].format = VK_FORMAT_R32G32B32_SFLOAT;
|
||||
attribute_descriptions[1].format = VK_FORMAT_R32G32B32A32_SFLOAT;
|
||||
attribute_descriptions[1].offset = offsetof(struct rse_vertex_t, color);
|
||||
|
||||
attribute_descriptions[2].binding = 0;
|
||||
@@ -640,7 +640,7 @@ static void fill_color_blend_state_info(VkPipelineColorBlendStateCreateInfo* col
|
||||
color_blending->sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
|
||||
color_blending->pNext = NULL;
|
||||
color_blending->flags = 0U;
|
||||
color_blending->logicOpEnable = VK_TRUE;
|
||||
color_blending->logicOpEnable = VK_FALSE;
|
||||
color_blending->logicOp = VK_LOGIC_OP_COPY;
|
||||
color_blending->attachmentCount = 1U;
|
||||
color_blending->pAttachments = color_blend_attachment;
|
||||
|
||||
Reference in new issue
Block a user