Use camera class
This commit is contained in:
parent
9310c34f07
commit
983c5d95da
1 changed files with 9 additions and 22 deletions
|
|
@ -87,12 +87,12 @@ public:
|
|||
|
||||
VulkanExample() : VulkanExampleBase(ENABLE_VALIDATION)
|
||||
{
|
||||
zoom = -7.5f;
|
||||
zoomSpeed = 2.5f;
|
||||
rotation = { 0.0f, -90.0f, 0.0f };
|
||||
cameraPos = glm::vec3(2.5f, 2.5f, 0.0f);
|
||||
title = "Multisampling";
|
||||
settings.overlay = true;
|
||||
camera.type = Camera::CameraType::lookat;
|
||||
camera.setPerspective(60.0f, (float)width / (float)height, 0.1f, 256.0f);
|
||||
camera.setRotation(glm::vec3(0.0f, -90.0f, 0.0f));
|
||||
camera.setTranslation(glm::vec3(2.5f, 2.5f, -7.5f));
|
||||
}
|
||||
|
||||
~VulkanExample()
|
||||
|
|
@ -681,19 +681,8 @@ public:
|
|||
|
||||
void updateUniformBuffers()
|
||||
{
|
||||
// Vertex shader
|
||||
glm::mat4 viewMatrix = glm::mat4(1.0f);
|
||||
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);
|
||||
viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom));
|
||||
|
||||
float offset = 0.5f;
|
||||
int uboIndex = 1;
|
||||
uboVS.model = glm::mat4(1.0f);
|
||||
uboVS.model = viewMatrix * glm::translate(uboVS.model, cameraPos);
|
||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
|
||||
uboVS.projection = camera.matrices.perspective;
|
||||
uboVS.model = camera.matrices.view;
|
||||
memcpy(uniformBuffer.mapped, &uboVS, sizeof(uboVS));
|
||||
}
|
||||
|
||||
|
|
@ -731,12 +720,10 @@ public:
|
|||
if (!prepared)
|
||||
return;
|
||||
draw();
|
||||
}
|
||||
|
||||
virtual void viewChanged()
|
||||
{
|
||||
if (camera.updated) {
|
||||
updateUniformBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the maximum sample count usable by the platform
|
||||
VkSampleCountFlagBits getMaxUsableSampleCount()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue