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)
|
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";
|
title = "Multisampling";
|
||||||
settings.overlay = true;
|
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()
|
~VulkanExample()
|
||||||
|
|
@ -681,19 +681,8 @@ public:
|
||||||
|
|
||||||
void updateUniformBuffers()
|
void updateUniformBuffers()
|
||||||
{
|
{
|
||||||
// Vertex shader
|
uboVS.projection = camera.matrices.perspective;
|
||||||
glm::mat4 viewMatrix = glm::mat4(1.0f);
|
uboVS.model = camera.matrices.view;
|
||||||
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));
|
|
||||||
|
|
||||||
memcpy(uniformBuffer.mapped, &uboVS, sizeof(uboVS));
|
memcpy(uniformBuffer.mapped, &uboVS, sizeof(uboVS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -731,12 +720,10 @@ public:
|
||||||
if (!prepared)
|
if (!prepared)
|
||||||
return;
|
return;
|
||||||
draw();
|
draw();
|
||||||
}
|
if (camera.updated) {
|
||||||
|
|
||||||
virtual void viewChanged()
|
|
||||||
{
|
|
||||||
updateUniformBuffers();
|
updateUniformBuffers();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Returns the maximum sample count usable by the platform
|
// Returns the maximum sample count usable by the platform
|
||||||
VkSampleCountFlagBits getMaxUsableSampleCount()
|
VkSampleCountFlagBits getMaxUsableSampleCount()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue