diff --git a/samples/02_box/box.cpp b/samples/02_box/box.cpp index 16e2623..b81447c 100644 --- a/samples/02_box/box.cpp +++ b/samples/02_box/box.cpp @@ -51,7 +51,6 @@ Pipeline CreatePipeline(const Device *device, const Swapchain *swapchain); struct Vertex { vec3 m_Position; - vec3 m_Color; constexpr static vk::VertexInputBindingDescription GetBinding(const u32 binding) @@ -59,7 +58,7 @@ struct Vertex return {.binding = binding, .stride = sizeof(Vertex), .inputRate = vk::VertexInputRate::eVertex}; } - constexpr static eastl::array + constexpr static eastl::array GetAttributes(const u32 binding) { return { @@ -69,12 +68,6 @@ struct Vertex .format = vk::Format::eR32G32B32Sfloat, .offset = offsetof(Vertex, m_Position), }, - vk::VertexInputAttributeDescription{ - .location = 1, - .binding = binding, - .format = vk::Format::eR32G32B32Sfloat, - .offset = offsetof(Vertex, m_Color), - }, }; } }; @@ -121,7 +114,7 @@ main(int, char **) Camera camera = { .m_Model = {1.0f}, - .m_View = glm::lookAt(vec3(-1.0f, 0.0f, 1.0f), vec3(0.0f), vec3(0.0f, 1.0f, 0.0f)), + .m_View = glm::lookAt(vec3(0.0f, 2.0f, 2.0f), vec3(0.0f), vec3(0.0f, 1.0f, 0.0f)), .m_Perspective = glm::perspective( 70_deg, Cast(swapchain.m_Extent.width) / Cast(swapchain.m_Extent.height), 0.1f, 100.0f), }; @@ -166,10 +159,17 @@ main(int, char **) // eastl::array vertices{}; eastl::array vertices = { - Vertex{.m_Position = {-0.5f, -0.5f, 0.0f}, .m_Color = {1.0f, 0.0f, 0.0f}}, - Vertex{.m_Position = {0.5f, -0.5f, 0.0f}, .m_Color = {0.0f, 1.0f, 0.0f}}, - Vertex{.m_Position = {0.0f, 0.5f, 0.0f}, .m_Color = {0.0f, 0.0f, 1.0f}}, + vec3(-0.5f, -0.5f, -0.5f), vec3(0.5f, -0.5f, -0.5f), vec3(0.5f, 0.5f, -0.5f), vec3(0.5f, 0.5f, -0.5f), + vec3(-0.5f, 0.5f, -0.5f), vec3(-0.5f, -0.5f, -0.5f), vec3(-0.5f, -0.5f, 0.5f), vec3(0.5f, -0.5f, 0.5f), + vec3(0.5f, 0.5f, 0.5f), vec3(0.5f, 0.5f, 0.5f), vec3(-0.5f, 0.5f, 0.5f), vec3(-0.5f, -0.5f, 0.5f), + vec3(-0.5f, 0.5f, 0.5f), vec3(-0.5f, 0.5f, -0.5f), vec3(-0.5f, -0.5f, -0.5f), vec3(-0.5f, -0.5f, -0.5f), + vec3(-0.5f, -0.5f, 0.5f), vec3(-0.5f, 0.5f, 0.5f), vec3(0.5f, 0.5f, 0.5f), vec3(0.5f, 0.5f, -0.5f), + vec3(0.5f, -0.5f, -0.5f), vec3(0.5f, -0.5f, -0.5f), vec3(0.5f, -0.5f, 0.5f), vec3(0.5f, 0.5f, 0.5f), + vec3(-0.5f, -0.5f, -0.5f), vec3(0.5f, -0.5f, -0.5f), vec3(0.5f, -0.5f, 0.5f), vec3(0.5f, -0.5f, 0.5f), + vec3(-0.5f, -0.5f, 0.5f), vec3(-0.5f, -0.5f, -0.5f), vec3(-0.5f, 0.5f, -0.5f), vec3(0.5f, 0.5f, -0.5f), + vec3(0.5f, 0.5f, 0.5f), vec3(0.5f, 0.5f, 0.5f), vec3(-0.5f, 0.5f, 0.5f), vec3(-0.5f, 0.5f, -0.5f), }; + VertexBuffer vbo; vbo.Init(&device, vertices.size() * sizeof vertices[0], "VBO"); { @@ -348,7 +348,7 @@ main(int, char **) cmd.bindDescriptorSets(vk::PipelineBindPoint::eGraphics, pipeline.m_Layout, 0, 1, &descriptorSet, 0, nullptr); usize offsets = 0; cmd.bindVertexBuffers(0, 1, &vbo.m_Buffer, &offsets); - cmd.draw(3, 1, 0, 0); + cmd.draw(Cast(vertices.size()), 1, 0, 0); cmd.endRendering(); diff --git a/samples/02_box/shader/box.vert.glsl b/samples/02_box/shader/box.vert.glsl index ff21bbd..8ed5995 100644 --- a/samples/02_box/shader/box.vert.glsl +++ b/samples/02_box/shader/box.vert.glsl @@ -2,7 +2,6 @@ #pragma shader_stage(vertex) layout(location=0) in vec4 position; -layout(location=1) in vec4 color; layout(location=0) out vec3 outColor; @@ -14,5 +13,5 @@ layout(binding=0) uniform Camera { void main() { gl_Position = ubo.proj * ubo.view * ubo.model * vec4(position.xyz, 1.0f); - outColor = vec3(color.rgb); + outColor = vec3(0.5f, 0.3f, 0.1f); } \ No newline at end of file