diff --git a/base/vulkanexamplebase.h b/base/vulkanexamplebase.h index 4ffbf287..5ea112e2 100644 --- a/base/vulkanexamplebase.h +++ b/base/vulkanexamplebase.h @@ -35,8 +35,6 @@ #include "vulkanTextureLoader.hpp" #include "vulkanMeshLoader.hpp" -#define deg_to_rad(deg) deg * float(M_PI / 180) - class VulkanExampleBase { private: diff --git a/bloom/bloom.cpp b/bloom/bloom.cpp index 3b56c567..d04d8a89 100644 --- a/bloom/bloom.cpp +++ b/bloom/bloom.cpp @@ -1185,17 +1185,17 @@ public: void updateUniformBuffersScene() { // UFO - ubos.fullscreen.projection = glm::perspective(deg_to_rad(45.0f), (float)width / (float)height, 0.1f, 256.0f); + ubos.fullscreen.projection = glm::perspective(glm::radians(45.0f), (float)width / (float)height, 0.1f, 256.0f); glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, -1.0f, zoom)); ubos.fullscreen.model = viewMatrix * - glm::translate(glm::mat4(), glm::vec3(sin(deg_to_rad(timer * 360.0f)) * 0.25f, 0.0f, cos(deg_to_rad(timer * 360.0f)) * 0.25f)); + glm::translate(glm::mat4(), glm::vec3(sin(glm::radians(timer * 360.0f)) * 0.25f, 0.0f, cos(glm::radians(timer * 360.0f)) * 0.25f)); - ubos.fullscreen.model = glm::rotate(ubos.fullscreen.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - ubos.fullscreen.model = glm::rotate(ubos.fullscreen.model, -sinf(deg_to_rad(timer * 360.0f)) * 0.15f, glm::vec3(1.0f, 0.0f, 0.0f)); - ubos.fullscreen.model = glm::rotate(ubos.fullscreen.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - ubos.fullscreen.model = glm::rotate(ubos.fullscreen.model, deg_to_rad(timer * 360.0f), glm::vec3(0.0f, 1.0f, 0.0f)); - ubos.fullscreen.model = glm::rotate(ubos.fullscreen.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + ubos.fullscreen.model = glm::rotate(ubos.fullscreen.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); + ubos.fullscreen.model = glm::rotate(ubos.fullscreen.model, -sinf(glm::radians(timer * 360.0f)) * 0.15f, glm::vec3(1.0f, 0.0f, 0.0f)); + ubos.fullscreen.model = glm::rotate(ubos.fullscreen.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); + ubos.fullscreen.model = glm::rotate(ubos.fullscreen.model, glm::radians(timer * 360.0f), glm::vec3(0.0f, 1.0f, 0.0f)); + ubos.fullscreen.model = glm::rotate(ubos.fullscreen.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); uint8_t *pData; VkResult err = vkMapMemory(device, uniformData.vsFullScreen.memory, 0, sizeof(ubos.fullscreen), 0, (void **)&pData); @@ -1204,12 +1204,12 @@ public: vkUnmapMemory(device, uniformData.vsFullScreen.memory); // Skybox - ubos.skyBox.projection = glm::perspective(deg_to_rad(45.0f), (float)width / (float)height, 0.1f, 256.0f); + ubos.skyBox.projection = glm::perspective(glm::radians(45.0f), (float)width / (float)height, 0.1f, 256.0f); ubos.skyBox.model = glm::mat4(); - ubos.skyBox.model = glm::rotate(ubos.skyBox.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - ubos.skyBox.model = glm::rotate(ubos.skyBox.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - ubos.skyBox.model = glm::rotate(ubos.skyBox.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + ubos.skyBox.model = glm::rotate(ubos.skyBox.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); + ubos.skyBox.model = glm::rotate(ubos.skyBox.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); + ubos.skyBox.model = glm::rotate(ubos.skyBox.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); err = vkMapMemory(device, uniformData.vsSkyBox.memory, 0, sizeof(ubos.skyBox), 0, (void **)&pData); assert(!err); diff --git a/computeparticles/computeparticles.cpp b/computeparticles/computeparticles.cpp index 5ffe255f..71b6b7ba 100644 --- a/computeparticles/computeparticles.cpp +++ b/computeparticles/computeparticles.cpp @@ -635,7 +635,7 @@ public: void updateUniformBuffers() { computeUbo.deltaT = frameTimer * 5.0f; - computeUbo.destX = sin(deg_to_rad(timer*360.0)) * 0.75f; + computeUbo.destX = sin(glm::radians(timer*360.0)) * 0.75f; computeUbo.destY = 0; uint8_t *pData; VkResult err = vkMapMemory(device, uniformData.computeShader.ubo.memory, 0, sizeof(computeUbo), 0, (void **)&pData); diff --git a/computeshader/computeshader.cpp b/computeshader/computeshader.cpp index 678f4255..011642e1 100644 --- a/computeshader/computeshader.cpp +++ b/computeshader/computeshader.cpp @@ -743,14 +743,14 @@ public: { // Vertex shader glm::mat4 viewMatrix = glm::mat4(); - uboVS.projection = glm::perspective(deg_to_rad(60.0f), (float)width*0.5f / (float)height, 0.1f, 256.0f); + uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width*0.5f / (float)height, 0.1f, 256.0f); viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom)); uboVS.model = glm::mat4(); uboVS.model = viewMatrix * glm::translate(uboVS.model, glm::vec3(0, 0, 0)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + 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)); uint8_t *pData; VkResult err = vkMapMemory(device, uniformDataVS.memory, 0, sizeof(uboVS), 0, (void **)&pData); diff --git a/deferred/deferred.cpp b/deferred/deferred.cpp index 39f61a75..83b00bdd 100644 --- a/deferred/deferred.cpp +++ b/deferred/deferred.cpp @@ -1193,11 +1193,11 @@ public: void updateUniformBufferDeferredMatrices() { - uboOffscreenVS.projection = glm::perspective(deg_to_rad(45.0f), (float)width / (float)height, 0.1f, 256.0f); + uboOffscreenVS.projection = glm::perspective(glm::radians(45.0f), (float)width / (float)height, 0.1f, 256.0f); uboOffscreenVS.view = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom)); - uboOffscreenVS.view = glm::rotate(uboOffscreenVS.view, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - uboOffscreenVS.view = glm::rotate(uboOffscreenVS.view, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - uboOffscreenVS.view = glm::rotate(uboOffscreenVS.view, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + uboOffscreenVS.view = glm::rotate(uboOffscreenVS.view, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); + uboOffscreenVS.view = glm::rotate(uboOffscreenVS.view, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); + uboOffscreenVS.view = glm::rotate(uboOffscreenVS.view, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); uboOffscreenVS.model = glm::mat4(); uboOffscreenVS.model = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.25f, 0.0f)); diff --git a/displacement/displacement.cpp b/displacement/displacement.cpp index 0668e220..7cdd16d6 100644 --- a/displacement/displacement.cpp +++ b/displacement/displacement.cpp @@ -530,16 +530,16 @@ public: { // Tessellation eval glm::mat4 viewMatrix = glm::mat4(); - uboTE.projection = glm::perspective(deg_to_rad(45.0f), (float)(width* ((splitScreen) ? 0.5f : 1.0f)) / (float)height, 0.1f, 256.0f); + uboTE.projection = glm::perspective(glm::radians(45.0f), (float)(width* ((splitScreen) ? 0.5f : 1.0f)) / (float)height, 0.1f, 256.0f); viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom)); float offset = 0.5f; int uboIndex = 1; uboTE.model = glm::mat4(); uboTE.model = viewMatrix * glm::translate(uboTE.model, glm::vec3(0, 0, 0)); - uboTE.model = glm::rotate(uboTE.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - uboTE.model = glm::rotate(uboTE.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - uboTE.model = glm::rotate(uboTE.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + uboTE.model = glm::rotate(uboTE.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); + uboTE.model = glm::rotate(uboTE.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); + uboTE.model = glm::rotate(uboTE.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); uint8_t *pData; VkResult err = vkMapMemory(device, uniformDataTE.memory, 0, sizeof(uboTE), 0, (void **)&pData); diff --git a/distancefieldfonts/distancefieldfonts.cpp b/distancefieldfonts/distancefieldfonts.cpp index eb8c1dae..f0d65490 100644 --- a/distancefieldfonts/distancefieldfonts.cpp +++ b/distancefieldfonts/distancefieldfonts.cpp @@ -688,14 +688,14 @@ public: { // Vertex shader glm::mat4 viewMatrix = glm::mat4(); - uboVS.projection = glm::perspective(deg_to_rad(splitScreen ? 45.0f : 60.0f), (float)width / (float)(height * ((splitScreen) ? 0.5f : 1.0f)), 0.001f, 256.0f); + uboVS.projection = glm::perspective(glm::radians(splitScreen ? 45.0f : 60.0f), (float)width / (float)(height * ((splitScreen) ? 0.5f : 1.0f)), 0.001f, 256.0f); viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom)); uboVS.model = glm::mat4(); uboVS.model = viewMatrix * glm::translate(uboVS.model, glm::vec3(0, 0, 0)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + 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)); uint8_t *pData; VkResult err = vkMapMemory(device, uniformData.vs.memory, 0, sizeof(uboVS), 0, (void **)&pData); diff --git a/gears/gears.cpp b/gears/gears.cpp index 812ca108..e3b28997 100644 --- a/gears/gears.cpp +++ b/gears/gears.cpp @@ -359,7 +359,7 @@ public: void updateUniformBuffers() { - glm::mat4 perspective = glm::perspective(deg_to_rad(60.0f), (float)width / (float)height, 0.001f, 256.0f); + glm::mat4 perspective = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f); for (auto& gear : gears) { gear->updateUniformBuffer(perspective, rotation, zoom, timer * 360.0f); diff --git a/gears/vulkangear.cpp b/gears/vulkangear.cpp index 5091e58f..8b1f1d2d 100644 --- a/gears/vulkangear.cpp +++ b/gears/vulkangear.cpp @@ -244,20 +244,20 @@ void VulkanGear::updateUniformBuffer(glm::mat4 perspective, glm::vec3 rotation, glm::vec3(-1.0, -1.5, 0), glm::vec3(0, 1, 0) ); - ubo.view = glm::rotate(ubo.view, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - ubo.view = glm::rotate(ubo.view, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); + ubo.view = glm::rotate(ubo.view, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); + ubo.view = glm::rotate(ubo.view, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); ubo.model = glm::mat4(); ubo.model = glm::translate(ubo.model, pos); rotation.z = (rotSpeed * timer) + rotOffset; - ubo.model = glm::rotate(ubo.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + ubo.model = glm::rotate(ubo.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); ubo.normal = glm::inverseTranspose(ubo.view * ubo.model); //ubo.lightPos = lightPos; ubo.lightPos = glm::vec3(0.0f, 0.0f, 2.5f); - ubo.lightPos.x = sin(deg_to_rad(timer)) * 8.0f; - ubo.lightPos.z = cos(deg_to_rad(timer)) * 8.0f; + ubo.lightPos.x = sin(glm::radians(timer)) * 8.0f; + ubo.lightPos.z = cos(glm::radians(timer)) * 8.0f; uint8_t *pData; VkResult err = vkMapMemory(device, uniformData.memory, 0, sizeof(ubo), 0, (void **)&pData); @@ -265,7 +265,7 @@ void VulkanGear::updateUniformBuffer(glm::mat4 perspective, glm::vec3 rotation, memcpy(pData, &ubo, sizeof(ubo)); vkUnmapMemory(device, uniformData.memory); - #undef deg_to_rad + #undef glm::radians } void VulkanGear::setupDescriptorSet(VkDescriptorPool pool, VkDescriptorSetLayout descriptorSetLayout) diff --git a/geometryshader/geometryshader.cpp b/geometryshader/geometryshader.cpp index c24a517f..146b5965 100644 --- a/geometryshader/geometryshader.cpp +++ b/geometryshader/geometryshader.cpp @@ -438,16 +438,16 @@ public: { // Vertex shader glm::mat4 viewMatrix = glm::mat4(); - uboVS.projection = glm::perspective(deg_to_rad(60.0f), (float)width / (float)height, 0.001f, 256.0f); + uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f); viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom)); float offset = 0.5f; int uboIndex = 1; uboVS.model = glm::mat4(); uboVS.model = viewMatrix * glm::translate(uboVS.model, glm::vec3(0, 0, 0)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + 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)); uint8_t *pData; VkResult err = vkMapMemory(device, uniformData.VS.memory, 0, sizeof(uboVS), 0, (void **)&pData); diff --git a/instancing/instancing.cpp b/instancing/instancing.cpp index a59ead01..e662db63 100644 --- a/instancing/instancing.cpp +++ b/instancing/instancing.cpp @@ -426,7 +426,7 @@ public: { // Instance model matrix uboVS.instance[index].model = glm::translate(glm::mat4(), glm::vec3(x * offset, y * offset, z * offset)); - uboVS.instance[index].model = glm::rotate(uboVS.instance[index].model, deg_to_rad(-45.0f), glm::vec3(0.0f, 1.0f, 0.0f)); + uboVS.instance[index].model = glm::rotate(uboVS.instance[index].model, glm::radians(-45.0f), glm::vec3(0.0f, 1.0f, 0.0f)); // Instance color (randomized) uboVS.instance[index].color = glm::vec4((float)(rand() % 255) / 255.0f, (float)(rand() % 255) / 255.0f, (float)(rand() % 255) / 255.0f, 1.0); index++; @@ -451,13 +451,13 @@ public: // Only updates the uniform buffer block part containing the global matrices // Projection - uboVS.matrices.projection = glm::perspective(deg_to_rad(60.0f), (float)width / (float)height, 0.001f, 256.0f); + uboVS.matrices.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f); // View uboVS.matrices.view = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom)); - uboVS.matrices.view = glm::rotate(uboVS.matrices.view, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - uboVS.matrices.view = glm::rotate(uboVS.matrices.view, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - uboVS.matrices.view = glm::rotate(uboVS.matrices.view, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + uboVS.matrices.view = glm::rotate(uboVS.matrices.view, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); + uboVS.matrices.view = glm::rotate(uboVS.matrices.view, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); + uboVS.matrices.view = glm::rotate(uboVS.matrices.view, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); // Only update the matrices part of the uniform buffer uint8_t *pData; diff --git a/mesh/mesh.cpp b/mesh/mesh.cpp index 859c354f..62fa5dfd 100644 --- a/mesh/mesh.cpp +++ b/mesh/mesh.cpp @@ -497,16 +497,16 @@ public: { // Vertex shader glm::mat4 viewMatrix = glm::mat4(); - uboVS.projection = glm::perspective(deg_to_rad(60.0f), (float)width / (float)height, 0.1f, 256.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(); uboVS.model = viewMatrix * glm::translate(uboVS.model, glm::vec3(0, 0, 0)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + 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)); uint8_t *pData; VkResult err = vkMapMemory(device, uniformData.vsScene.memory, 0, sizeof(uboVS), 0, (void **)&pData); diff --git a/occlusionquery/occlusionquery.cpp b/occlusionquery/occlusionquery.cpp index 3f6e1218..dcdafd03 100644 --- a/occlusionquery/occlusionquery.cpp +++ b/occlusionquery/occlusionquery.cpp @@ -619,13 +619,13 @@ public: { // Vertex shader glm::mat4 viewMatrix = glm::mat4(); - uboVS.projection = glm::perspective(deg_to_rad(60.0f), (float)width / (float)height, 0.1f, 256.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)); glm::mat4 rotMatrix = glm::mat4(); - rotMatrix = glm::rotate(rotMatrix, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - rotMatrix = glm::rotate(rotMatrix, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - rotMatrix = glm::rotate(rotMatrix, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + rotMatrix = glm::rotate(rotMatrix, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); + rotMatrix = glm::rotate(rotMatrix, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); + rotMatrix = glm::rotate(rotMatrix, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); uboVS.model = glm::mat4(); uboVS.model = viewMatrix * rotMatrix;; diff --git a/offscreen/offscreen.cpp b/offscreen/offscreen.cpp index 10b44290..19504b51 100644 --- a/offscreen/offscreen.cpp +++ b/offscreen/offscreen.cpp @@ -1036,13 +1036,13 @@ public: void updateUniformBuffers() { // Mesh - ubos.vsShared.projection = glm::perspective(deg_to_rad(60.0f), (float)width / (float)height, 0.1f, 256.0f); + ubos.vsShared.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f); glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom)); ubos.vsShared.model = viewMatrix * glm::translate(glm::mat4(), glm::vec3(0, 0, 0)); - ubos.vsShared.model = glm::rotate(ubos.vsShared.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - ubos.vsShared.model = glm::rotate(ubos.vsShared.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - ubos.vsShared.model = glm::rotate(ubos.vsShared.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + ubos.vsShared.model = glm::rotate(ubos.vsShared.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); + ubos.vsShared.model = glm::rotate(ubos.vsShared.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); + ubos.vsShared.model = glm::rotate(ubos.vsShared.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); ubos.vsShared.model = glm::translate(ubos.vsShared.model, meshPos); @@ -1054,9 +1054,9 @@ public: // Mirror ubos.vsShared.model = viewMatrix * glm::translate(glm::mat4(), glm::vec3(0, 0, 0)); - ubos.vsShared.model = glm::rotate(ubos.vsShared.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - ubos.vsShared.model = glm::rotate(ubos.vsShared.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - ubos.vsShared.model = glm::rotate(ubos.vsShared.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + ubos.vsShared.model = glm::rotate(ubos.vsShared.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); + ubos.vsShared.model = glm::rotate(ubos.vsShared.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); + ubos.vsShared.model = glm::rotate(ubos.vsShared.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); err = vkMapMemory(device, uniformData.vsMirror.memory, 0, sizeof(ubos.vsShared), 0, (void **)&pData); assert(!err); @@ -1075,13 +1075,13 @@ public: void updateUniformBufferOffscreen() { - ubos.vsShared.projection = glm::perspective(deg_to_rad(60.0f), (float)width / (float)height, 0.1f, 256.0f); + ubos.vsShared.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f); glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom)); ubos.vsShared.model = viewMatrix * glm::translate(glm::mat4(), glm::vec3(0, 0, 0)); - ubos.vsShared.model = glm::rotate(ubos.vsShared.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - ubos.vsShared.model = glm::rotate(ubos.vsShared.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - ubos.vsShared.model = glm::rotate(ubos.vsShared.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + ubos.vsShared.model = glm::rotate(ubos.vsShared.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); + ubos.vsShared.model = glm::rotate(ubos.vsShared.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); + ubos.vsShared.model = glm::rotate(ubos.vsShared.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); ubos.vsShared.model = glm::scale(ubos.vsShared.model, glm::vec3(1.0f, -1.0f, 1.0f)); ubos.vsShared.model = glm::translate(ubos.vsShared.model, meshPos); diff --git a/parallaxmapping/parallaxmapping.cpp b/parallaxmapping/parallaxmapping.cpp index 4bbaba47..55232c8c 100644 --- a/parallaxmapping/parallaxmapping.cpp +++ b/parallaxmapping/parallaxmapping.cpp @@ -525,21 +525,21 @@ public: { // Vertex shader glm::mat4 viewMatrix = glm::mat4(); - ubos.vertexShader.projection = glm::perspective(deg_to_rad(45.0f), (float)(width* ((splitScreen) ? 0.5f : 1.0f)) / (float)height, 0.001f, 256.0f); + ubos.vertexShader.projection = glm::perspective(glm::radians(45.0f), (float)(width* ((splitScreen) ? 0.5f : 1.0f)) / (float)height, 0.001f, 256.0f); viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom)); ubos.vertexShader.model = glm::mat4(); ubos.vertexShader.model = viewMatrix * glm::translate(ubos.vertexShader.model, glm::vec3(0, 0, 0)); - ubos.vertexShader.model = glm::rotate(ubos.vertexShader.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - ubos.vertexShader.model = glm::rotate(ubos.vertexShader.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - ubos.vertexShader.model = glm::rotate(ubos.vertexShader.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + ubos.vertexShader.model = glm::rotate(ubos.vertexShader.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); + ubos.vertexShader.model = glm::rotate(ubos.vertexShader.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); + ubos.vertexShader.model = glm::rotate(ubos.vertexShader.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); ubos.vertexShader.normal = glm::inverseTranspose(ubos.vertexShader.model); if (!paused) { - ubos.vertexShader.lightPos.x = sin(deg_to_rad(timer * 360.0f)) * 0.5; - ubos.vertexShader.lightPos.y = cos(deg_to_rad(timer * 360.0f)) * 0.5; + ubos.vertexShader.lightPos.x = sin(glm::radians(timer * 360.0f)) * 0.5; + ubos.vertexShader.lightPos.y = cos(glm::radians(timer * 360.0f)) * 0.5; } ubos.vertexShader.cameraPos = glm::vec4(0.0, 0.0, zoom, 0.0); diff --git a/pipelines/pipelines.cpp b/pipelines/pipelines.cpp index 3beb67f9..2eb95d9d 100644 --- a/pipelines/pipelines.cpp +++ b/pipelines/pipelines.cpp @@ -540,14 +540,14 @@ public: void updateUniformBuffers() { - uboVS.projectionMatrix = glm::perspective(deg_to_rad(60.0f), (float)(width / 3.0f) / (float)height, 0.1f, 256.0f); + uboVS.projectionMatrix = glm::perspective(glm::radians(60.0f), (float)(width / 3.0f) / (float)height, 0.1f, 256.0f); uboVS.viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom)); uboVS.modelMatrix = glm::mat4(); - uboVS.modelMatrix = glm::rotate(uboVS.modelMatrix, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - uboVS.modelMatrix = glm::rotate(uboVS.modelMatrix, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - uboVS.modelMatrix = glm::rotate(uboVS.modelMatrix, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + uboVS.modelMatrix = glm::rotate(uboVS.modelMatrix, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); + uboVS.modelMatrix = glm::rotate(uboVS.modelMatrix, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); + uboVS.modelMatrix = glm::rotate(uboVS.modelMatrix, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); uint8_t *pData; VkResult err = vkMapMemory(device, uniformDataVS.memory, 0, sizeof(uboVS), 0, (void **)&pData); diff --git a/pushconstants/pushconstants.cpp b/pushconstants/pushconstants.cpp index f1c9ee0f..e3bdb84b 100644 --- a/pushconstants/pushconstants.cpp +++ b/pushconstants/pushconstants.cpp @@ -157,15 +157,15 @@ public: // Update light positions // w component = light radius scale #define r 7.5f -#define sin_t sin(deg_to_rad(timer * 360)) -#define cos_t cos(deg_to_rad(timer * 360)) +#define sin_t sin(glm::radians(timer * 360)) +#define cos_t cos(glm::radians(timer * 360)) #define y -4.0f pushConstants[0] = glm::vec4(r * 1.1 * sin_t, y, r * 1.1 * cos_t, 1.0f); pushConstants[1] = glm::vec4(-r * sin_t, y, -r * cos_t, 1.0f); pushConstants[2] = glm::vec4(r * 0.85f * sin_t, y, -sin_t * 2.5f, 1.5f); pushConstants[3] = glm::vec4(0.0f, y, r * 1.25f * cos_t, 1.5f); pushConstants[4] = glm::vec4(r * 2.25f * cos_t, y, 0.0f, 1.25f); - pushConstants[5] = glm::vec4(r * 2.5f * cos(deg_to_rad(timer * 360)), y, r * 2.5f * sin_t, 1.25f); + pushConstants[5] = glm::vec4(r * 2.5f * cos(glm::radians(timer * 360)), y, r * 2.5f * sin_t, 1.25f); #undef r #undef y #undef sin_t @@ -457,15 +457,15 @@ public: { // Vertex shader glm::mat4 viewMatrix = glm::mat4(); - uboVS.projection = glm::perspective(deg_to_rad(60.0f), (float)width / (float)height, 0.001f, 256.0f); + uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f); viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 2.0f, zoom)); float offset = 0.5f; int uboIndex = 1; uboVS.model = viewMatrix * glm::translate(glm::mat4(), glm::vec3(0, 0, 0)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + 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)); uint8_t *pData; VkResult err = vkMapMemory(device, uniformData.vertexShader.memory, 0, sizeof(uboVS), 0, (void **)&pData); diff --git a/radialblur/radialblur.cpp b/radialblur/radialblur.cpp index f39748aa..89403584 100644 --- a/radialblur/radialblur.cpp +++ b/radialblur/radialblur.cpp @@ -980,15 +980,15 @@ public: // Update uniform buffers for rendering the 3D scene void updateUniformBuffersScene() { - uboQuadVS.projection = glm::perspective(deg_to_rad(45.0f), (float)width / (float)height, 1.0f, 256.0f); + uboQuadVS.projection = glm::perspective(glm::radians(45.0f), (float)width / (float)height, 1.0f, 256.0f); glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom)); uboQuadVS.model = glm::mat4(); uboQuadVS.model = viewMatrix * glm::translate(uboQuadVS.model, glm::vec3(0, 0, 0)); - uboQuadVS.model = glm::rotate(uboQuadVS.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - uboQuadVS.model = glm::rotate(uboQuadVS.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - uboQuadVS.model = glm::rotate(uboQuadVS.model, deg_to_rad(timer * 360.0f), glm::vec3(0.0f, 1.0f, 0.0f)); - uboQuadVS.model = glm::rotate(uboQuadVS.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + uboQuadVS.model = glm::rotate(uboQuadVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); + uboQuadVS.model = glm::rotate(uboQuadVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); + uboQuadVS.model = glm::rotate(uboQuadVS.model, glm::radians(timer * 360.0f), glm::vec3(0.0f, 1.0f, 0.0f)); + uboQuadVS.model = glm::rotate(uboQuadVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); uint8_t *pData; VkResult err = vkMapMemory(device, uniformData.vsQuad.memory, 0, sizeof(uboQuadVS), 0, (void **)&pData); diff --git a/shadowmappingomni/shadowmappingomni.cpp b/shadowmappingomni/shadowmappingomni.cpp index a1834d1a..8de4acc2 100644 --- a/shadowmappingomni/shadowmappingomni.cpp +++ b/shadowmappingomni/shadowmappingomni.cpp @@ -437,24 +437,24 @@ public: switch (faceIndex) { case 0: // POSITIVE_X - viewMatrix = glm::rotate(viewMatrix, deg_to_rad(90.0f), glm::vec3(0.0f, 1.0f, 0.0f)); - viewMatrix = glm::rotate(viewMatrix, deg_to_rad(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)); + viewMatrix = glm::rotate(viewMatrix, glm::radians(90.0f), glm::vec3(0.0f, 1.0f, 0.0f)); + viewMatrix = glm::rotate(viewMatrix, glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)); break; case 1: // NEGATIVE_X - viewMatrix = glm::rotate(viewMatrix, deg_to_rad(-90), glm::vec3(0.0f, 1.0f, 0.0f)); - viewMatrix = glm::rotate(viewMatrix, deg_to_rad(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)); + viewMatrix = glm::rotate(viewMatrix, glm::radians(-90.0f), glm::vec3(0.0f, 1.0f, 0.0f)); + viewMatrix = glm::rotate(viewMatrix, glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)); break; case 2: // POSITIVE_Y - viewMatrix = glm::rotate(viewMatrix, deg_to_rad(-90), glm::vec3(1.0f, 0.0f, 0.0f)); + viewMatrix = glm::rotate(viewMatrix, glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f)); break; case 3: // NEGATIVE_Y - viewMatrix = glm::rotate(viewMatrix, deg_to_rad(90), glm::vec3(1.0f, 0.0f, 0.0f)); + viewMatrix = glm::rotate(viewMatrix, glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f)); break; case 4: // POSITIVE_Z - viewMatrix = glm::rotate(viewMatrix, deg_to_rad(180), glm::vec3(1.0f, 0.0f, 0.0f)); + viewMatrix = glm::rotate(viewMatrix, glm::radians(180.0f), glm::vec3(1.0f, 0.0f, 0.0f)); break; case 5: // NEGATIVE_Z - viewMatrix = glm::rotate(viewMatrix, deg_to_rad(180), glm::vec3(0.0f, 0.0f, 1.0f)); + viewMatrix = glm::rotate(viewMatrix, glm::radians(180.0f), glm::vec3(0.0f, 0.0f, 1.0f)); break; } @@ -986,13 +986,13 @@ public: void updateUniformBuffers() { // 3D scene - uboVSscene.projection = glm::perspective(deg_to_rad(45.0f), (float)width / (float)height, zNear, zFar); + uboVSscene.projection = glm::perspective(glm::radians(45.0f), (float)width / (float)height, zNear, zFar); uboVSscene.view = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, displayCubeMap ? 0.0f : zoom)); uboVSscene.model = glm::mat4(); - uboVSscene.model = glm::rotate(uboVSscene.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - uboVSscene.model = glm::rotate(uboVSscene.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - uboVSscene.model = glm::rotate(uboVSscene.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + uboVSscene.model = glm::rotate(uboVSscene.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); + uboVSscene.model = glm::rotate(uboVSscene.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); + uboVSscene.model = glm::rotate(uboVSscene.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); uboVSscene.lightPos = lightPos; @@ -1005,8 +1005,8 @@ public: void updateUniformBufferOffscreen() { - lightPos.x = sin(deg_to_rad(timer * 360.0f)) * 1.0f; - lightPos.z = cos(deg_to_rad(timer * 360.0f)) * 1.0f; + lightPos.x = sin(glm::radians(timer * 360.0f)) * 1.0f; + lightPos.z = cos(glm::radians(timer * 360.0f)) * 1.0f; uboOffscreenVS.projection = glm::perspective((float)(M_PI / 2.0), 1.0f, zNear, zFar); diff --git a/skeletalanimation/skeletalanimation.cpp b/skeletalanimation/skeletalanimation.cpp index 6d477694..3723c51a 100644 --- a/skeletalanimation/skeletalanimation.cpp +++ b/skeletalanimation/skeletalanimation.cpp @@ -796,16 +796,16 @@ public: void updateUniformBuffers() { // Vertex shader - uboVS.projection = glm::perspective(deg_to_rad(60.0f), (float)width / (float)height, 0.1f, 256.0f); + uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f); glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom)); - viewMatrix = glm::rotate(viewMatrix, deg_to_rad(90), glm::vec3(1.0f, 0.0f, 0.0f)); + viewMatrix = glm::rotate(viewMatrix, glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f)); uboVS.model = glm::mat4(); uboVS.model = viewMatrix * glm::translate(uboVS.model, glm::vec3(0.0f, 0.0f, -3.5f)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 1.0f, 0.0f)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(-rotation.y), glm::vec3(0.0f, 0.0f, 1.0f)); + 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.z), glm::vec3(0.0f, 1.0f, 0.0f)); + uboVS.model = glm::rotate(uboVS.model, glm::radians(-rotation.y), glm::vec3(0.0f, 0.0f, 1.0f)); // Update bones std::vector boneTransforms; diff --git a/tessellation/tessellation.cpp b/tessellation/tessellation.cpp index 700262e5..7529480c 100644 --- a/tessellation/tessellation.cpp +++ b/tessellation/tessellation.cpp @@ -508,16 +508,16 @@ public: { // Tessellation eval glm::mat4 viewMatrix = glm::mat4(); - uboTE.projection = glm::perspective(deg_to_rad(45.0f), (float)(width* ((splitScreen) ? 0.5f : 1.0f)) / (float)height, 0.1f, 256.0f); + uboTE.projection = glm::perspective(glm::radians(45.0f), (float)(width* ((splitScreen) ? 0.5f : 1.0f)) / (float)height, 0.1f, 256.0f); viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom)); float offset = 0.5f; int uboIndex = 1; uboTE.model = glm::mat4(); uboTE.model = viewMatrix * glm::translate(uboTE.model, glm::vec3(0, 0, 0)); - uboTE.model = glm::rotate(uboTE.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - uboTE.model = glm::rotate(uboTE.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - uboTE.model = glm::rotate(uboTE.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + uboTE.model = glm::rotate(uboTE.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); + uboTE.model = glm::rotate(uboTE.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); + uboTE.model = glm::rotate(uboTE.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); uint8_t *pData; VkResult err = vkMapMemory(device, uniformDataTE.memory, 0, sizeof(uboTE), 0, (void **)&pData); diff --git a/texture/texture.cpp b/texture/texture.cpp index 41e87730..ddfbef6a 100644 --- a/texture/texture.cpp +++ b/texture/texture.cpp @@ -790,14 +790,14 @@ public: { // Vertex shader glm::mat4 viewMatrix = glm::mat4(); - uboVS.projection = glm::perspective(deg_to_rad(60.0f), (float)width / (float)height, 0.001f, 256.0f); + uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f); viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom)); uboVS.model = glm::mat4(); uboVS.model = viewMatrix * glm::translate(uboVS.model, glm::vec3(0, 0, 0)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + 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)); uint8_t *pData; VkResult err = vkMapMemory(device, uniformDataVS.memory, 0, sizeof(uboVS), 0, (void **)&pData); diff --git a/texturearray/texturearray.cpp b/texturearray/texturearray.cpp index 68425abc..e8db7e12 100644 --- a/texturearray/texturearray.cpp +++ b/texturearray/texturearray.cpp @@ -667,7 +667,7 @@ public: { // Instance model matrix uboVS.instance[i].model = glm::translate(glm::mat4(), glm::vec3(0.0f, i * offset - center, 0.0f)); - uboVS.instance[i].model = glm::rotate(uboVS.instance[i].model, deg_to_rad(60.0f), glm::vec3(1.0f, 0.0f, 0.0f)); + uboVS.instance[i].model = glm::rotate(uboVS.instance[i].model, glm::radians(60.0f), glm::vec3(1.0f, 0.0f, 0.0f)); // Instance texture array index uboVS.instance[i].arrayIndex.x = i; } @@ -689,13 +689,13 @@ public: // Only updates the uniform buffer block part containing the global matrices // Projection - uboVS.matrices.projection = glm::perspective(deg_to_rad(60.0f), (float)width / (float)height, 0.001f, 256.0f); + uboVS.matrices.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f); // View uboVS.matrices.view = glm::translate(glm::mat4(), glm::vec3(0.0f, -1.0f, zoom)); - uboVS.matrices.view = glm::rotate(uboVS.matrices.view, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - uboVS.matrices.view = glm::rotate(uboVS.matrices.view, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - uboVS.matrices.view = glm::rotate(uboVS.matrices.view, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + uboVS.matrices.view = glm::rotate(uboVS.matrices.view, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); + uboVS.matrices.view = glm::rotate(uboVS.matrices.view, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); + uboVS.matrices.view = glm::rotate(uboVS.matrices.view, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); // Only update the matrices part of the uniform buffer uint8_t *pData; diff --git a/texturecubemap/texturecubemap.cpp b/texturecubemap/texturecubemap.cpp index a62d1586..9521f1f7 100644 --- a/texturecubemap/texturecubemap.cpp +++ b/texturecubemap/texturecubemap.cpp @@ -670,14 +670,14 @@ public: { // 3D object glm::mat4 viewMatrix = glm::mat4(); - uboVS.projection = glm::perspective(deg_to_rad(60.0f), (float)width / (float)height, 0.001f, 256.0f); + uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f); viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom)); uboVS.model = glm::mat4(); uboVS.model = viewMatrix * glm::translate(uboVS.model, glm::vec3(0, 0, 0)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + 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)); uint8_t *pData; VkResult err = vkMapMemory(device, uniformData.objectVS.memory, 0, sizeof(uboVS), 0, (void **)&pData); @@ -687,13 +687,13 @@ public: // Skysphere viewMatrix = glm::mat4(); - uboVS.projection = glm::perspective(deg_to_rad(60.0f), (float)width / (float)height, 0.001f, 256.0f); + uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f); uboVS.model = glm::mat4(); uboVS.model = viewMatrix * glm::translate(uboVS.model, glm::vec3(0, 0, 0)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + 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)); err = vkMapMemory(device, uniformData.skyboxVS.memory, 0, sizeof(uboVS), 0, (void **)&pData); assert(!err); diff --git a/vulkanscene/vulkanscene.cpp b/vulkanscene/vulkanscene.cpp index f390cec0..b576ded9 100644 --- a/vulkanscene/vulkanscene.cpp +++ b/vulkanscene/vulkanscene.cpp @@ -538,7 +538,7 @@ public: void updateUniformBuffers() { - uboVS.projection = glm::perspective(deg_to_rad(60.0f), (float)width / (float)height, 0.1f, 256.0f); + uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f); uboVS.view = glm::lookAt( glm::vec3(0, 0, -zoom), @@ -547,9 +547,9 @@ public: ); uboVS.model = glm::mat4(); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + 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.normal = glm::inverseTranspose(uboVS.view * uboVS.model);