Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions attachments/22_descriptor_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,8 @@ class HelloTriangleApplication
.pColorAttachments = &attachmentInfo};
commandBuffer.beginRendering(renderingInfo);
commandBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, *graphicsPipeline);
commandBuffer.setViewport(0, vk::Viewport(0.0f, 0.0f, static_cast<float>(swapChainExtent.width), static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
// Negative height flips Y for Vulkan; see Uniform buffers.
commandBuffer.setViewport(0, vk::Viewport(0.0f, static_cast<float>(swapChainExtent.height), static_cast<float>(swapChainExtent.width), -static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
commandBuffer.setScissor(0, vk::Rect2D(vk::Offset2D(0, 0), swapChainExtent));
commandBuffer.bindVertexBuffers(0, *vertexBuffer, {0});
commandBuffer.bindIndexBuffer(*indexBuffer, 0, vk::IndexTypeValue<decltype(indices)::value_type>::value);
Expand Down Expand Up @@ -680,7 +681,6 @@ class HelloTriangleApplication
ubo.view = lookAt(glm::vec3(2.0f, 2.0f, 2.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
ubo.proj =
glm::perspective(glm::radians(45.0f), static_cast<float>(swapChainExtent.width) / static_cast<float>(swapChainExtent.height), 0.1f, 10.0f);
ubo.proj[1][1] *= -1;

memcpy(uniformBuffersMapped[currentImage], &ubo, sizeof(ubo));
}
Expand Down
4 changes: 2 additions & 2 deletions attachments/23_descriptor_sets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,8 @@ class HelloTriangleApplication
.pColorAttachments = &attachmentInfo};
commandBuffer.beginRendering(renderingInfo);
commandBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, *graphicsPipeline);
commandBuffer.setViewport(0, vk::Viewport(0.0f, 0.0f, static_cast<float>(swapChainExtent.width), static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
// Negative height flips Y for Vulkan; see Uniform buffers.
commandBuffer.setViewport(0, vk::Viewport(0.0f, static_cast<float>(swapChainExtent.height), static_cast<float>(swapChainExtent.width), -static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
commandBuffer.setScissor(0, vk::Rect2D(vk::Offset2D(0, 0), swapChainExtent));
commandBuffer.bindVertexBuffers(0, *vertexBuffer, {0});
commandBuffer.bindIndexBuffer(*indexBuffer, 0, vk::IndexTypeValue<decltype(indices)::value_type>::value);
Expand Down Expand Up @@ -715,7 +716,6 @@ class HelloTriangleApplication
ubo.view = lookAt(glm::vec3(2.0f, 2.0f, 2.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
ubo.proj =
glm::perspective(glm::radians(45.0f), static_cast<float>(swapChainExtent.width) / static_cast<float>(swapChainExtent.height), 0.1f, 10.0f);
ubo.proj[1][1] *= -1;

memcpy(uniformBuffersMapped[currentImage], &ubo, sizeof(ubo));
}
Expand Down
4 changes: 2 additions & 2 deletions attachments/24_texture_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,8 @@ class HelloTriangleApplication
.pColorAttachments = &attachmentInfo};
commandBuffer.beginRendering(renderingInfo);
commandBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, *graphicsPipeline);
commandBuffer.setViewport(0, vk::Viewport(0.0f, 0.0f, static_cast<float>(swapChainExtent.width), static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
// Negative height flips Y for Vulkan; see Uniform buffers.
commandBuffer.setViewport(0, vk::Viewport(0.0f, static_cast<float>(swapChainExtent.height), static_cast<float>(swapChainExtent.width), -static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
commandBuffer.setScissor(0, vk::Rect2D(vk::Offset2D(0, 0), swapChainExtent));
commandBuffer.bindVertexBuffers(0, *vertexBuffer, {0});
commandBuffer.bindIndexBuffer(*indexBuffer, 0, vk::IndexTypeValue<decltype(indices)::value_type>::value);
Expand Down Expand Up @@ -842,7 +843,6 @@ class HelloTriangleApplication
ubo.view = lookAt(glm::vec3(2.0f, 2.0f, 2.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
ubo.proj =
glm::perspective(glm::radians(45.0f), static_cast<float>(swapChainExtent.width) / static_cast<float>(swapChainExtent.height), 0.1f, 10.0f);
ubo.proj[1][1] *= -1;

memcpy(uniformBuffersMapped[currentImage], &ubo, sizeof(ubo));
}
Expand Down
4 changes: 2 additions & 2 deletions attachments/25_sampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,8 @@ class HelloTriangleApplication
.pColorAttachments = &attachmentInfo};
commandBuffer.beginRendering(renderingInfo);
commandBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, *graphicsPipeline);
commandBuffer.setViewport(0, vk::Viewport(0.0f, 0.0f, static_cast<float>(swapChainExtent.width), static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
// Negative height flips Y for Vulkan; see Uniform buffers.
commandBuffer.setViewport(0, vk::Viewport(0.0f, static_cast<float>(swapChainExtent.height), static_cast<float>(swapChainExtent.width), -static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
commandBuffer.setScissor(0, vk::Rect2D(vk::Offset2D(0, 0), swapChainExtent));
commandBuffer.bindVertexBuffers(0, *vertexBuffer, {0});
commandBuffer.bindIndexBuffer(*indexBuffer, 0, vk::IndexTypeValue<decltype(indices)::value_type>::value);
Expand Down Expand Up @@ -868,7 +869,6 @@ class HelloTriangleApplication
ubo.view = lookAt(glm::vec3(2.0f, 2.0f, 2.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
ubo.proj =
glm::perspective(glm::radians(45.0f), static_cast<float>(swapChainExtent.width) / static_cast<float>(swapChainExtent.height), 0.1f, 10.0f);
ubo.proj[1][1] *= -1;

memcpy(uniformBuffersMapped[currentImage], &ubo, sizeof(ubo));
}
Expand Down
4 changes: 2 additions & 2 deletions attachments/26_texture_mapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,8 @@ class HelloTriangleApplication
.pColorAttachments = &attachmentInfo};
commandBuffer.beginRendering(renderingInfo);
commandBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, *graphicsPipeline);
commandBuffer.setViewport(0, vk::Viewport(0.0f, 0.0f, static_cast<float>(swapChainExtent.width), static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
// Negative height flips Y for Vulkan; see Uniform buffers.
commandBuffer.setViewport(0, vk::Viewport(0.0f, static_cast<float>(swapChainExtent.height), static_cast<float>(swapChainExtent.width), -static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
commandBuffer.setScissor(0, vk::Rect2D(vk::Offset2D(0, 0), swapChainExtent));
commandBuffer.bindVertexBuffers(0, *vertexBuffer, {0});
commandBuffer.bindIndexBuffer(*indexBuffer, 0, vk::IndexTypeValue<decltype(indices)::value_type>::value);
Expand Down Expand Up @@ -884,7 +885,6 @@ class HelloTriangleApplication
ubo.view = lookAt(glm::vec3(2.0f, 2.0f, 2.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
ubo.proj =
glm::perspective(glm::radians(45.0f), static_cast<float>(swapChainExtent.width) / static_cast<float>(swapChainExtent.height), 0.1f, 10.0f);
ubo.proj[1][1] *= -1;

memcpy(uniformBuffersMapped[currentImage], &ubo, sizeof(ubo));
}
Expand Down
4 changes: 2 additions & 2 deletions attachments/27_depth_buffering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,8 @@ class HelloTriangleApplication

commandBuffer.beginRendering(renderingInfo);
commandBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, *graphicsPipeline);
commandBuffer.setViewport(0, vk::Viewport(0.0f, 0.0f, static_cast<float>(swapChainExtent.width), static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
// Negative height flips Y for Vulkan; see Uniform buffers.
commandBuffer.setViewport(0, vk::Viewport(0.0f, static_cast<float>(swapChainExtent.height), static_cast<float>(swapChainExtent.width), -static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
commandBuffer.setScissor(0, vk::Rect2D(vk::Offset2D(0, 0), swapChainExtent));
commandBuffer.bindVertexBuffers(0, *vertexBuffer, {0});
commandBuffer.bindIndexBuffer(*indexBuffer, 0, vk::IndexTypeValue<decltype(indices)::value_type>::value);
Expand Down Expand Up @@ -963,7 +964,6 @@ class HelloTriangleApplication
ubo.view = lookAt(glm::vec3(2.0f, 2.0f, 2.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
ubo.proj =
glm::perspective(glm::radians(45.0f), static_cast<float>(swapChainExtent.width) / static_cast<float>(swapChainExtent.height), 0.1f, 10.0f);
ubo.proj[1][1] *= -1;

memcpy(uniformBuffersMapped[currentImage], &ubo, sizeof(ubo));
}
Expand Down
4 changes: 2 additions & 2 deletions attachments/28_model_loading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,8 @@ class HelloTriangleApplication

commandBuffer.beginRendering(renderingInfo);
commandBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, *graphicsPipeline);
commandBuffer.setViewport(0, vk::Viewport(0.0f, 0.0f, static_cast<float>(swapChainExtent.width), static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
// Negative height flips Y for Vulkan; see Uniform buffers.
commandBuffer.setViewport(0, vk::Viewport(0.0f, static_cast<float>(swapChainExtent.height), static_cast<float>(swapChainExtent.width), -static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
commandBuffer.setScissor(0, vk::Rect2D(vk::Offset2D(0, 0), swapChainExtent));
commandBuffer.bindVertexBuffers(0, *vertexBuffer, {0});
commandBuffer.bindIndexBuffer(*indexBuffer, 0, vk::IndexTypeValue<decltype(indices)::value_type>::value);
Expand Down Expand Up @@ -1017,7 +1018,6 @@ class HelloTriangleApplication
ubo.view = lookAt(glm::vec3(2.0f, 2.0f, 2.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
ubo.proj =
glm::perspective(glm::radians(45.0f), static_cast<float>(swapChainExtent.width) / static_cast<float>(swapChainExtent.height), 0.1f, 10.0f);
ubo.proj[1][1] *= -1;

memcpy(uniformBuffersMapped[currentImage], &ubo, sizeof(ubo));
}
Expand Down
4 changes: 2 additions & 2 deletions attachments/29_mipmapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,8 @@ class HelloTriangleApplication

commandBuffer.beginRendering(renderingInfo);
commandBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, *graphicsPipeline);
commandBuffer.setViewport(0, vk::Viewport(0.0f, 0.0f, static_cast<float>(swapChainExtent.width), static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
// Negative height flips Y for Vulkan; see Uniform buffers.
commandBuffer.setViewport(0, vk::Viewport(0.0f, static_cast<float>(swapChainExtent.height), static_cast<float>(swapChainExtent.width), -static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
commandBuffer.setScissor(0, vk::Rect2D(vk::Offset2D(0, 0), swapChainExtent));
commandBuffer.bindVertexBuffers(0, *vertexBuffer, {0});
commandBuffer.bindIndexBuffer(*indexBuffer, 0, vk::IndexTypeValue<decltype(indices)::value_type>::value);
Expand Down Expand Up @@ -1103,7 +1104,6 @@ class HelloTriangleApplication
ubo.view = lookAt(glm::vec3(2.0f, 2.0f, 2.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
ubo.proj =
glm::perspective(glm::radians(45.0f), static_cast<float>(swapChainExtent.width) / static_cast<float>(swapChainExtent.height), 0.1f, 10.0f);
ubo.proj[1][1] *= -1;

memcpy(uniformBuffersMapped[currentImage], &ubo, sizeof(ubo));
}
Expand Down
4 changes: 2 additions & 2 deletions attachments/30_multisampling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,8 @@ class HelloTriangleApplication
.pDepthAttachment = &depthAttachment};
commandBuffer.beginRendering(renderingInfo);
commandBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, *graphicsPipeline);
commandBuffer.setViewport(0, vk::Viewport(0.0f, 0.0f, static_cast<float>(swapChainExtent.width), static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
// Negative height flips Y for Vulkan; see Uniform buffers.
commandBuffer.setViewport(0, vk::Viewport(0.0f, static_cast<float>(swapChainExtent.height), static_cast<float>(swapChainExtent.width), -static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
commandBuffer.setScissor(0, vk::Rect2D(vk::Offset2D(0, 0), swapChainExtent));
commandBuffer.bindVertexBuffers(0, *vertexBuffer, {0});
commandBuffer.bindIndexBuffer(*indexBuffer, 0, vk::IndexTypeValue<decltype(indices)::value_type>::value);
Expand Down Expand Up @@ -1179,7 +1180,6 @@ class HelloTriangleApplication
ubo.view = lookAt(glm::vec3(2.0f, 2.0f, 2.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
ubo.proj =
glm::perspective(glm::radians(45.0f), static_cast<float>(swapChainExtent.width) / static_cast<float>(swapChainExtent.height), 0.1f, 10.0f);
ubo.proj[1][1] *= -1;

memcpy(uniformBuffersMapped[currentImage], &ubo, sizeof(ubo));
}
Expand Down
4 changes: 2 additions & 2 deletions attachments/32_ecosystem_utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,8 @@ class HelloTriangleApplication

// Common rendering commands
commandBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, *graphicsPipeline);
commandBuffer.setViewport(0, vk::Viewport(0.0f, 0.0f, static_cast<float>(swapChainExtent.width), static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
// Negative height flips Y for Vulkan; see Uniform buffers.
commandBuffer.setViewport(0, vk::Viewport(0.0f, static_cast<float>(swapChainExtent.height), static_cast<float>(swapChainExtent.width), -static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
commandBuffer.setScissor(0, vk::Rect2D(vk::Offset2D(0, 0), swapChainExtent));
commandBuffer.bindVertexBuffers(0, *vertexBuffer, {0});
commandBuffer.bindIndexBuffer(*indexBuffer, 0, vk::IndexType::eUint32);
Expand Down Expand Up @@ -1582,7 +1583,6 @@ class HelloTriangleApplication
ubo.model = rotate(glm::mat4(1.0f), time * glm::radians(90.0f), glm::vec3(0.0f, 0.0f, 1.0f));
ubo.view = lookAt(glm::vec3(2.0f, 2.0f, 2.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
ubo.proj = glm::perspective(glm::radians(45.0f), static_cast<float>(swapChainExtent.width) / static_cast<float>(swapChainExtent.height), 0.1f, 10.0f);
ubo.proj[1][1] *= -1;

memcpy(uniformBuffersMapped[currentImage], &ubo, sizeof(ubo));
}
Expand Down
6 changes: 3 additions & 3 deletions attachments/33_vulkan_profiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1443,11 +1443,12 @@ class HelloTriangleApplication

commandBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, *graphicsPipeline);

// Negative height flips Y for Vulkan; see Uniform buffers.
vk::Viewport viewport{
.x = 0.0f,
.y = 0.0f,
.y = static_cast<float>(swapChainExtent.height),
.width = static_cast<float>(swapChainExtent.width),
.height = static_cast<float>(swapChainExtent.height),
.height = -static_cast<float>(swapChainExtent.height),
.minDepth = 0.0f,
.maxDepth = 1.0f};
commandBuffer.setViewport(0, viewport);
Expand Down Expand Up @@ -1554,7 +1555,6 @@ class HelloTriangleApplication
ubo.model = glm::rotate(glm::mat4(1.0f), time * glm::radians(90.0f), glm::vec3(0.0f, 0.0f, 1.0f));
ubo.view = glm::lookAt(glm::vec3(2.0f, 2.0f, 2.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
ubo.proj = glm::perspective(glm::radians(45.0f), swapChainExtent.width / (float) swapChainExtent.height, 0.1f, 10.0f);
ubo.proj[1][1] *= -1;

memcpy(uniformBuffersMapped[currentImage], &ubo, sizeof(ubo));
}
Expand Down
6 changes: 3 additions & 3 deletions attachments/34_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1293,11 +1293,12 @@ class HelloTriangleApplication
commandBuffer.beginRenderPass(renderPassInfo, vk::SubpassContents::eInline);
commandBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, *graphicsPipeline);

// Negative height flips Y for Vulkan; see Uniform buffers.
vk::Viewport viewport{
.x = 0.0f,
.y = 0.0f,
.y = static_cast<float>(swapChainExtent.height),
.width = static_cast<float>(swapChainExtent.width),
.height = static_cast<float>(swapChainExtent.height),
.height = -static_cast<float>(swapChainExtent.height),
.minDepth = 0.0f,
.maxDepth = 1.0f};
commandBuffer.setViewport(0, viewport);
Expand Down Expand Up @@ -1750,7 +1751,6 @@ class HelloTriangleApplication
ubo.model = glm::rotate(glm::mat4(1.0f), time * glm::radians(90.0f), glm::vec3(0.0f, 0.0f, 1.0f));
ubo.view = glm::lookAt(glm::vec3(2.0f, 2.0f, 2.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
ubo.proj = glm::perspective(glm::radians(45.0f), swapChainExtent.width / (float) swapChainExtent.height, 0.1f, 10.0f);
ubo.proj[1][1] *= -1;

void *data;
data = uniformBuffersMemory[currentImage].mapMemory(0, sizeof(ubo));
Expand Down
4 changes: 2 additions & 2 deletions attachments/35_gltf_ktx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,8 @@ class VulkanApplication
.pDepthAttachment = &depthAttachmentInfo};
commandBuffer.beginRendering(renderingInfo);
commandBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, *graphicsPipeline);
commandBuffer.setViewport(0, vk::Viewport(0.0f, 0.0f, static_cast<float>(swapChainExtent.width), static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
// Negative height flips Y for Vulkan; see Uniform buffers.
commandBuffer.setViewport(0, vk::Viewport(0.0f, static_cast<float>(swapChainExtent.height), static_cast<float>(swapChainExtent.width), -static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
commandBuffer.setScissor(0, vk::Rect2D(vk::Offset2D(0, 0), swapChainExtent));
commandBuffer.bindVertexBuffers(0, *vertexBuffer, {0});
commandBuffer.bindIndexBuffer(*indexBuffer, 0, vk::IndexType::eUint32);
Expand Down Expand Up @@ -1381,7 +1382,6 @@ class VulkanApplication
ubo.model = continuousRotation * initialRotation;
ubo.view = lookAt(glm::vec3(2.0f, 2.0f, 2.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
ubo.proj = glm::perspective(glm::radians(45.0f), static_cast<float>(swapChainExtent.width) / static_cast<float>(swapChainExtent.height), 0.1f, 10.0f);
ubo.proj[1][1] *= -1;

memcpy(uniformBuffersMapped[currentImage], &ubo, sizeof(ubo));
}
Expand Down
4 changes: 2 additions & 2 deletions attachments/36_multiple_objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,8 @@ class VulkanApplication
.pDepthAttachment = &depthAttachmentInfo};
commandBuffer.beginRendering(renderingInfo);
commandBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, *graphicsPipeline);
commandBuffer.setViewport(0, vk::Viewport(0.0f, 0.0f, static_cast<float>(swapChainExtent.width), static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
// Negative height flips Y for Vulkan; see Uniform buffers.
commandBuffer.setViewport(0, vk::Viewport(0.0f, static_cast<float>(swapChainExtent.height), static_cast<float>(swapChainExtent.width), -static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
commandBuffer.setScissor(0, vk::Rect2D(vk::Offset2D(0, 0), swapChainExtent));

// Bind vertex and index buffers (shared by all objects)
Expand Down Expand Up @@ -1496,7 +1497,6 @@ class VulkanApplication
// Camera and projection matrices (shared by all objects)
glm::mat4 view = glm::lookAt(glm::vec3(2.0f, 2.0f, 6.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f));
glm::mat4 proj = glm::perspective(glm::radians(45.0f), static_cast<float>(swapChainExtent.width) / static_cast<float>(swapChainExtent.height), 0.1f, 20.0f);
proj[1][1] *= -1;

// Update uniform buffers for each object
for (auto &gameObject : gameObjects)
Expand Down
4 changes: 2 additions & 2 deletions attachments/38_ray_tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,8 @@ class VulkanRaytracingApplication
commandBuffer.beginRendering(renderingInfo);

commandBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, *graphicsPipeline);
commandBuffer.setViewport(0, vk::Viewport(0.0f, 0.0f, static_cast<float>(swapChainExtent.width), static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
// Negative height flips Y for Vulkan; see Uniform buffers.
commandBuffer.setViewport(0, vk::Viewport(0.0f, static_cast<float>(swapChainExtent.height), static_cast<float>(swapChainExtent.width), -static_cast<float>(swapChainExtent.height), 0.0f, 1.0f));
commandBuffer.setScissor(0, vk::Rect2D(vk::Offset2D(0, 0), swapChainExtent));
commandBuffer.bindVertexBuffers(0, *vertexBuffer, {0});
commandBuffer.bindIndexBuffer(*indexBuffer, 0, vk::IndexType::eUint32);
Expand Down Expand Up @@ -1736,7 +1737,6 @@ class VulkanRaytracingApplication
ubo.model = rotate(glm::mat4(1.0f), time * 0.1f * glm::radians(90.0f), glm::vec3(0.0f, 0.0f, 1.0f));
ubo.view = lookAt(eye, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
ubo.proj = glm::perspective(glm::radians(45.0f), static_cast<float>(swapChainExtent.width) / static_cast<float>(swapChainExtent.height), 0.1f, 10.0f);
ubo.proj[1][1] *= -1;
ubo.cameraPos = eye;

memcpy(uniformBuffersMapped[currentImage], &ubo, sizeof(ubo));
Expand Down
Loading
Loading