Merge pull request #4 from Jiga228/render

Modificate render
This commit is contained in:
Danil
2025-10-23 20:42:53 +07:00
committed by GitHub
3 changed files with 18 additions and 9 deletions
+1 -1
View File
@@ -86,7 +86,7 @@ std::array<VkVertexInputAttributeDescription, 2> RenderEngine::Vertex::get_verte
// Bind vertex loc
descriptions[0].binding = 0;
descriptions[0].location = 0;
descriptions[0].format = VK_FORMAT_R32G32_SFLOAT;
descriptions[0].format = VK_FORMAT_R32G32B32_SFLOAT;
descriptions[0].offset = offsetof(Vertex, pos);
// Bind color
+15 -6
View File
@@ -39,7 +39,7 @@ class RenderEngine
};
struct Vertex
{
glm::vec2 pos;
glm::vec3 pos;
glm::vec3 color;
static VkVertexInputBindingDescription get_binding_description();
static std::array<VkVertexInputAttributeDescription, 2> get_vertex_attribute_descriptions();
@@ -51,13 +51,22 @@ class RenderEngine
};
const std::vector<Vertex> vertices_ = {
{{-0.5f, -0.5f}, {1.0f, 0.0f, 0.0f}},
{{0.5f, -0.5f}, {0.0f, 1.0f, 0.0f}},
{{0.5f, 0.5f}, {0.0f, 0.0f, 1.0f}},
{{-0.5f, 0.5f}, {1.0f, 1.0f, 1.0f}}
{{-0.5f, -0.5f, 0.5f}, {1.0f, 0.0f, 0.0f}},
{{0.5f, -0.5f, 0.5f}, {0.0f, 1.0f, 0.0f}},
{{0.5f, 0.5f, 0.5f}, {0.0f, 0.0f, 1.0f}},
{{-0.5f, 0.5f, 0.5f}, {1.0f, 1.0f, 1.0f}},
{{-0.5f, -0.5f, -0.5f}, {1.0f, 0.0f, 0.0f}},
{{0.5f, -0.5f, -0.5f}, {0.0f, 1.0f, 0.0f}},
{{0.5f, 0.5f, -0.5f}, {0.0f, 0.0f, 1.0f}},
{{-0.5f, 0.5f, -0.5f}, {1.0f, 1.0f, 1.0f}}
};
const std::vector<uint16_t> indices_ = {
0, 1, 2, 2, 3, 0
0, 1, 2, 2, 3, 0,
2, 1, 5, 5, 6, 2,
0, 3, 7, 7, 4, 0,
3, 2, 6, 6, 7, 3,
7, 6, 5, 5, 4, 7,
4, 5, 1, 1, 0, 4
};
ModelManager model_manager_;
+2 -2
View File
@@ -6,13 +6,13 @@ layout(binding = 0) uniform UniformBufferObject {
mat4 proj;
} ubo;
layout(location = 0) in vec2 inPosition;
layout(location = 0) in vec3 inPosition;
layout(location = 1) in vec3 inColor;
layout(location = 0) out vec3 fragColor;
void main()
{
gl_Position = ubo.proj * ubo.view * ubo.model * vec4(inPosition, 0.0, 1.0);
gl_Position = ubo.proj * ubo.view * ubo.model * vec4(inPosition, 1.0);
fragColor = inColor;
}