Properly use render target aspect ratio
This commit is contained in:
parent
a1d28c2df4
commit
3f96161dff
3 changed files with 5 additions and 4 deletions
|
@ -4,13 +4,14 @@
|
||||||
|
|
||||||
class Renderer;
|
class Renderer;
|
||||||
class World;
|
class World;
|
||||||
|
struct RenderTarget;
|
||||||
|
|
||||||
class WorldPass {
|
class WorldPass {
|
||||||
public:
|
public:
|
||||||
WorldPass(Renderer& renderer);
|
WorldPass(Renderer& renderer);
|
||||||
~WorldPass();
|
~WorldPass();
|
||||||
|
|
||||||
void render(World& world, VkCommandBuffer commandBuffer);
|
void render(VkCommandBuffer commandBuffer, World& world, RenderTarget* target);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createPipeline();
|
void createPipeline();
|
||||||
|
|
|
@ -79,7 +79,7 @@ void Renderer::render(World& world, RenderTarget* target) {
|
||||||
|
|
||||||
vkCmdBeginRenderPass(commandBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
|
vkCmdBeginRenderPass(commandBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
|
||||||
|
|
||||||
worldPass_->render(world, commandBuffer);
|
worldPass_->render(commandBuffer, world, target);
|
||||||
|
|
||||||
vkCmdEndRenderPass(commandBuffer);
|
vkCmdEndRenderPass(commandBuffer);
|
||||||
|
|
||||||
|
|
|
@ -16,12 +16,12 @@ WorldPass::~WorldPass() {
|
||||||
vkDestroyPipelineLayout(renderer_.getDevice(), pipelineLayout_, nullptr);
|
vkDestroyPipelineLayout(renderer_.getDevice(), pipelineLayout_, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldPass::render(World& world, VkCommandBuffer commandBuffer) {
|
void WorldPass::render(VkCommandBuffer commandBuffer, World& world, RenderTarget* target) {
|
||||||
vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_);
|
vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_);
|
||||||
|
|
||||||
for(const auto& mesh : world.meshes) {
|
for(const auto& mesh : world.meshes) {
|
||||||
glm::mat4 mvp;
|
glm::mat4 mvp;
|
||||||
mvp = glm::perspective(glm::radians(75.0f), 640.0f / 480.0f, 0.1f, 100.0f);
|
mvp = glm::perspective(glm::radians(75.0f), (float)target->extent.width / target->extent.height, 0.1f, 100.0f);
|
||||||
mvp *= glm::lookAt(glm::vec3(2), glm::vec3(0), glm::vec3(0, -1, 0));
|
mvp *= glm::lookAt(glm::vec3(2), glm::vec3(0), glm::vec3(0, -1, 0));
|
||||||
|
|
||||||
vkCmdPushConstants(commandBuffer, pipelineLayout_, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(glm::mat4), &mvp);
|
vkCmdPushConstants(commandBuffer, pipelineLayout_, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(glm::mat4), &mvp);
|
||||||
|
|
Reference in a new issue