diff --git a/projects/first_triangle/shaders/shader.vert b/projects/first_triangle/shaders/shader.vert index 246a3661031cc8d4582a12d4c8b91fce4af58cad..1d278d5f41f803bb657a303dcc95ffcd2a92fd6e 100644 --- a/projects/first_triangle/shaders/shader.vert +++ b/projects/first_triangle/shaders/shader.vert @@ -1,10 +1,21 @@ #version 450 #extension GL_ARB_separate_shader_objects : enable -layout(location = 0) in vec2 inPosition; layout(location = 0) out vec3 fragColor; void main() { - gl_Position = vec4(inPosition, 0.0, 1.0); - fragColor = vec3(1); + vec3 positions[3] = { + vec3(-0.5, 0.5, 0), + vec3( 0.5, 0.5, 0), + vec3(0, -0.5, 0) + }; + + vec3 colors[3] = { + vec3(1, 0, 0), + vec3(0, 1, 0), + vec3(0, 0, 1) + }; + + gl_Position = vec4(positions[gl_VertexIndex], 1.0); + fragColor = colors[gl_VertexIndex]; } \ No newline at end of file diff --git a/projects/first_triangle/shaders/vert.spv b/projects/first_triangle/shaders/vert.spv index 7692f2cf09e53183c613f81db748d798a2e18fab..bd1e0e682c52e6e38a5f5aba4eeaf8e73a70d741 100644 Binary files a/projects/first_triangle/shaders/vert.spv and b/projects/first_triangle/shaders/vert.spv differ diff --git a/src/vkcv/Core.cpp b/src/vkcv/Core.cpp index 3c113a7a31f548f372c02c2fdda94c9a9134b196..07e7b82a489f4c41624d596ede96afda7ac79eee 100644 --- a/src/vkcv/Core.cpp +++ b/src/vkcv/Core.cpp @@ -338,7 +338,7 @@ namespace vkcv void Core::renderTriangle(const PassHandle renderpassHandle, const PipelineHandle pipelineHandle, const int width, const int height) { const vk::RenderPass renderpass = m_PassManager->getVkPass(renderpassHandle); - const std::array<float, 4> clearColor = { 1.f, 1.f, 0.f, 1.f }; + const std::array<float, 4> clearColor = { 0.f, 0.f, 0.f, 1.f }; const vk::ClearValue clearValues(clearColor); const vk::Rect2D renderArea(vk::Offset2D(0, 0), vk::Extent2D(width, height)); const vk::ImageView imageView = m_swapchainImageViews[m_currentSwapchainImageIndex]; @@ -347,6 +347,10 @@ namespace vkcv const vk::RenderPassBeginInfo beginInfo(renderpass, framebuffer, renderArea, 1, &clearValues); const vk::SubpassContents subpassContents = {}; m_CommandResources.commandBuffer.beginRenderPass(beginInfo, subpassContents, {}); + + const vk::Pipeline pipeline = m_PipelineManager->getVkPipeline(pipelineHandle); + m_CommandResources.commandBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, pipeline, {}); + m_CommandResources.commandBuffer.draw(3, 1, 0, 0, {}); m_CommandResources.commandBuffer.endRenderPass(); } diff --git a/src/vkcv/PipelineManager.cpp b/src/vkcv/PipelineManager.cpp index 416356f4fe9831fbe52b163a2b895dd2247d0b0f..e6d6beea463f17c86d958c9080f34eb61e9076c2 100644 --- a/src/vkcv/PipelineManager.cpp +++ b/src/vkcv/PipelineManager.cpp @@ -71,11 +71,11 @@ namespace vkcv vk::VertexInputAttributeDescription vertexInputAttributeDescription(0, 0, vk::Format::eR32G32B32Sfloat, 0); vk::PipelineVertexInputStateCreateInfo pipelineVertexInputStateCreateInfo( - {}, - 1, - &vertexInputBindingDescription, - 1, - &vertexInputAttributeDescription + {}, // no vertex input until vertex buffer is implemented + 0, // 1, + nullptr, // &vertexInputBindingDescription, + 0, // 1, + nullptr // &vertexInputAttributeDescription ); // input assembly state