From 72f3e3715006bbbb735d33953913fee48e60b8d7 Mon Sep 17 00:00:00 2001 From: "N. Pattakos" Date: Fri, 7 Jan 2022 23:13:19 +0100 Subject: [PATCH] fix narrowing conversions (eg double to float, size_t to GLsizei) --- includes/learnopengl/mesh.h | 2 +- .../3.1.shaders_uniform/shaders_uniform.cpp | 4 +-- .../transformations_exercise2.cpp | 2 +- .../7.1.camera_circle/camera_circle.cpp | 4 +-- .../camera_keyboard_dt.cpp | 4 +-- .../camera_mouse_zoom.cpp | 9 ++++-- .../7.4.camera_class/camera_class.cpp | 9 ++++-- src/2.lighting/1.colors/colors.cpp | 9 ++++-- .../basic_lighting_diffuse.cpp | 9 ++++-- .../basic_lighting_specular.cpp | 8 +++-- src/2.lighting/3.1.materials/materials.cpp | 15 ++++++---- .../materials_exercise1.cpp | 8 +++-- .../lighting_maps_diffuse.cpp | 9 ++++-- .../lighting_maps_specular.cpp | 9 ++++-- .../lighting_maps_exercise4.cpp | 9 ++++-- .../light_casters_directional.cpp | 8 +++-- .../light_casters_point.cpp | 9 ++++-- .../light_casters_spot.cpp | 9 ++++-- .../light_casters_spot_soft.cpp | 9 ++++-- .../6.multiple_lights/multiple_lights.cpp | 29 ++++++++++--------- .../1.model_loading/model_loading.cpp | 9 ++++-- .../1.1.depth_testing/depth_testing.cpp | 9 ++++-- .../depth_testing_view.cpp | 9 ++++-- .../10.2.asteroids/asteroids.cpp | 15 ++++++---- .../asteroids_instanced.cpp | 17 ++++++----- .../anti_aliasing_msaa.cpp | 8 +++-- .../anti_aliasing_offscreen.cpp | 8 +++-- .../2.stencil_testing/stencil_testing.cpp | 11 ++++--- .../3.1.blending_discard/blending_discard.cpp | 8 +++-- .../3.2.blending_sort/blending_sorted.cpp | 8 +++-- .../5.1.framebuffers/framebuffers.cpp | 8 +++-- .../framebuffers_exercise1.cpp | 8 +++-- .../6.1.cubemaps_skybox/cubemaps_skybox.cpp | 8 +++-- .../cubemaps_environment_mapping.cpp | 8 +++-- .../8.advanced_glsl_ubo/advanced_glsl_ubo.cpp | 6 ++-- .../geometry_shader_exploding.cpp | 10 ++++--- .../normal_visualization.cpp | 8 +++-- .../1.advanced_lighting/advanced_lighting.cpp | 8 +++-- .../2.gamma_correction/gamma_correction.cpp | 8 +++-- .../shadow_mapping_depth.cpp | 9 ++++-- .../shadow_mapping_base.cpp | 8 +++-- .../3.1.3.shadow_mapping/shadow_mapping.cpp | 8 +++-- .../3.2.1.point_shadows/point_shadows.cpp | 10 ++++--- .../point_shadows_soft.cpp | 10 ++++--- .../4.normal_mapping/normal_mapping.cpp | 8 +++-- .../5.1.parallax_mapping/parallax_mapping.cpp | 10 ++++--- .../steep_parallax_mapping.cpp | 10 ++++--- .../parallax_occlusion_mapping.cpp | 10 ++++--- src/5.advanced_lighting/6.hdr/hdr.cpp | 8 +++-- src/5.advanced_lighting/7.bloom/bloom.cpp | 8 +++-- .../8.1.deferred_shading/deferred_shading.cpp | 24 ++++++++------- .../deferred_shading_volumes.cpp | 26 +++++++++-------- src/5.advanced_lighting/9.ssao/ssao.cpp | 14 +++++---- src/6.pbr/1.1.lighting/lighting.cpp | 15 ++++++---- .../lighting_textured.cpp | 15 ++++++---- .../ibl_irradiance_conversion.cpp | 15 ++++++---- .../2.1.2.ibl_irradiance/ibl_irradiance.cpp | 15 ++++++---- src/6.pbr/2.2.1.ibl_specular/ibl_specular.cpp | 19 +++++++----- .../ibl_specular_textured.cpp | 19 +++++++----- 59 files changed, 371 insertions(+), 238 deletions(-) diff --git a/includes/learnopengl/mesh.h b/includes/learnopengl/mesh.h index 36943a3..2287d0f 100644 --- a/includes/learnopengl/mesh.h +++ b/includes/learnopengl/mesh.h @@ -87,7 +87,7 @@ public: // draw mesh glBindVertexArray(VAO); - glDrawElements(GL_TRIANGLES, indices.size(), GL_UNSIGNED_INT, 0); + glDrawElements(GL_TRIANGLES, static_cast(indices.size()), GL_UNSIGNED_INT, 0); glBindVertexArray(0); // always good practice to set everything back to defaults once configured. diff --git a/src/1.getting_started/3.1.shaders_uniform/shaders_uniform.cpp b/src/1.getting_started/3.1.shaders_uniform/shaders_uniform.cpp index dde5a32..21c08c9 100644 --- a/src/1.getting_started/3.1.shaders_uniform/shaders_uniform.cpp +++ b/src/1.getting_started/3.1.shaders_uniform/shaders_uniform.cpp @@ -146,8 +146,8 @@ int main() glUseProgram(shaderProgram); // update shader uniform - float timeValue = glfwGetTime(); - float greenValue = sin(timeValue) / 2.0f + 0.5f; + auto timeValue = glfwGetTime(); + auto greenValue = static_cast(sin(timeValue) / 2.0 + 0.5); int vertexColorLocation = glGetUniformLocation(shaderProgram, "ourColor"); glUniform4f(vertexColorLocation, 0.0f, greenValue, 0.0f, 1.0f); diff --git a/src/1.getting_started/5.2.transformations_exercise2/transformations_exercise2.cpp b/src/1.getting_started/5.2.transformations_exercise2/transformations_exercise2.cpp index e499e4e..6343d11 100644 --- a/src/1.getting_started/5.2.transformations_exercise2/transformations_exercise2.cpp +++ b/src/1.getting_started/5.2.transformations_exercise2/transformations_exercise2.cpp @@ -184,7 +184,7 @@ int main() // --------------------- transform = glm::mat4(1.0f); // reset it to identity matrix transform = glm::translate(transform, glm::vec3(-0.5f, 0.5f, 0.0f)); - float scaleAmount = sin(glfwGetTime()); + auto scaleAmount = static_cast(sin(glfwGetTime())); transform = glm::scale(transform, glm::vec3(scaleAmount, scaleAmount, scaleAmount)); glUniformMatrix4fv(transformLoc, 1, GL_FALSE, &transform[0][0]); // this time take the matrix value array's first element as its memory pointer value diff --git a/src/1.getting_started/7.1.camera_circle/camera_circle.cpp b/src/1.getting_started/7.1.camera_circle/camera_circle.cpp index 1883540..a868227 100644 --- a/src/1.getting_started/7.1.camera_circle/camera_circle.cpp +++ b/src/1.getting_started/7.1.camera_circle/camera_circle.cpp @@ -222,8 +222,8 @@ int main() // camera/view transformation glm::mat4 view = glm::mat4(1.0f); // make sure to initialize matrix to identity matrix first float radius = 10.0f; - float camX = sin(glfwGetTime()) * radius; - float camZ = cos(glfwGetTime()) * radius; + auto camX = static_cast(sin(glfwGetTime()) * radius); + auto camZ = static_cast(cos(glfwGetTime()) * radius); view = glm::lookAt(glm::vec3(camX, 0.0f, camZ), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f)); ourShader.setMat4("view", view); diff --git a/src/1.getting_started/7.2.camera_keyboard_dt/camera_keyboard_dt.cpp b/src/1.getting_started/7.2.camera_keyboard_dt/camera_keyboard_dt.cpp index ea2df0f..5a23faa 100644 --- a/src/1.getting_started/7.2.camera_keyboard_dt/camera_keyboard_dt.cpp +++ b/src/1.getting_started/7.2.camera_keyboard_dt/camera_keyboard_dt.cpp @@ -212,7 +212,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -276,7 +276,7 @@ void processInput(GLFWwindow *window) if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) glfwSetWindowShouldClose(window, true); - float cameraSpeed = 2.5 * deltaTime; + auto cameraSpeed = static_cast(2.5 * deltaTime); if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS) cameraPos += cameraSpeed * cameraFront; if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS) diff --git a/src/1.getting_started/7.3.camera_mouse_zoom/camera_mouse_zoom.cpp b/src/1.getting_started/7.3.camera_mouse_zoom/camera_mouse_zoom.cpp index 195bc6c..8c717b7 100644 --- a/src/1.getting_started/7.3.camera_mouse_zoom/camera_mouse_zoom.cpp +++ b/src/1.getting_started/7.3.camera_mouse_zoom/camera_mouse_zoom.cpp @@ -221,7 +221,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -289,7 +289,7 @@ void processInput(GLFWwindow *window) if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) glfwSetWindowShouldClose(window, true); - float cameraSpeed = 2.5 * deltaTime; + auto cameraSpeed = static_cast(2.5 * deltaTime); if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS) cameraPos += cameraSpeed * cameraFront; if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS) @@ -311,8 +311,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; diff --git a/src/1.getting_started/7.4.camera_class/camera_class.cpp b/src/1.getting_started/7.4.camera_class/camera_class.cpp index e4c8376..f405899 100644 --- a/src/1.getting_started/7.4.camera_class/camera_class.cpp +++ b/src/1.getting_started/7.4.camera_class/camera_class.cpp @@ -216,7 +216,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -306,8 +306,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -328,5 +331,5 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } \ No newline at end of file diff --git a/src/2.lighting/1.colors/colors.cpp b/src/2.lighting/1.colors/colors.cpp index 92f3fa9..384e69b 100644 --- a/src/2.lighting/1.colors/colors.cpp +++ b/src/2.lighting/1.colors/colors.cpp @@ -157,7 +157,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -250,8 +250,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -272,5 +275,5 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } \ No newline at end of file diff --git a/src/2.lighting/2.1.basic_lighting_diffuse/basic_lighting_diffuse.cpp b/src/2.lighting/2.1.basic_lighting_diffuse/basic_lighting_diffuse.cpp index ec844cf..b8b519b 100644 --- a/src/2.lighting/2.1.basic_lighting_diffuse/basic_lighting_diffuse.cpp +++ b/src/2.lighting/2.1.basic_lighting_diffuse/basic_lighting_diffuse.cpp @@ -160,7 +160,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -254,8 +254,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -276,5 +279,5 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } \ No newline at end of file diff --git a/src/2.lighting/2.2.basic_lighting_specular/basic_lighting_specular.cpp b/src/2.lighting/2.2.basic_lighting_specular/basic_lighting_specular.cpp index fa85a4e..bc50fcc 100644 --- a/src/2.lighting/2.2.basic_lighting_specular/basic_lighting_specular.cpp +++ b/src/2.lighting/2.2.basic_lighting_specular/basic_lighting_specular.cpp @@ -160,7 +160,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -255,8 +255,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -277,5 +279,5 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } \ No newline at end of file diff --git a/src/2.lighting/3.1.materials/materials.cpp b/src/2.lighting/3.1.materials/materials.cpp index 5ec0f53..33d5da9 100644 --- a/src/2.lighting/3.1.materials/materials.cpp +++ b/src/2.lighting/3.1.materials/materials.cpp @@ -160,7 +160,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -180,9 +180,9 @@ int main() // light properties glm::vec3 lightColor; - lightColor.x = sin(glfwGetTime() * 2.0f); - lightColor.y = sin(glfwGetTime() * 0.7f); - lightColor.z = sin(glfwGetTime() * 1.3f); + lightColor.x = static_cast(sin(glfwGetTime() * 2.0)); + lightColor.y = static_cast(sin(glfwGetTime() * 0.7)); + lightColor.z = static_cast(sin(glfwGetTime() * 1.3)); glm::vec3 diffuseColor = lightColor * glm::vec3(0.5f); // decrease the influence glm::vec3 ambientColor = diffuseColor * glm::vec3(0.2f); // low influence lightingShader.setVec3("light.ambient", ambientColor); @@ -270,8 +270,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -292,5 +295,5 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } \ No newline at end of file diff --git a/src/2.lighting/3.2.materials_exercise1/materials_exercise1.cpp b/src/2.lighting/3.2.materials_exercise1/materials_exercise1.cpp index c5601f0..ea09d1a 100644 --- a/src/2.lighting/3.2.materials_exercise1/materials_exercise1.cpp +++ b/src/2.lighting/3.2.materials_exercise1/materials_exercise1.cpp @@ -160,7 +160,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -264,8 +264,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -286,5 +288,5 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } diff --git a/src/2.lighting/4.1.lighting_maps_diffuse_map/lighting_maps_diffuse.cpp b/src/2.lighting/4.1.lighting_maps_diffuse_map/lighting_maps_diffuse.cpp index dc73bb7..ed2f1ea 100644 --- a/src/2.lighting/4.1.lighting_maps_diffuse_map/lighting_maps_diffuse.cpp +++ b/src/2.lighting/4.1.lighting_maps_diffuse_map/lighting_maps_diffuse.cpp @@ -170,7 +170,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -276,8 +276,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -298,7 +301,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/2.lighting/4.2.lighting_maps_specular_map/lighting_maps_specular.cpp b/src/2.lighting/4.2.lighting_maps_specular_map/lighting_maps_specular.cpp index c529e7c..11fa264 100644 --- a/src/2.lighting/4.2.lighting_maps_specular_map/lighting_maps_specular.cpp +++ b/src/2.lighting/4.2.lighting_maps_specular_map/lighting_maps_specular.cpp @@ -172,7 +172,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -279,8 +279,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -301,7 +304,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/2.lighting/4.4.lighting_maps_exercise4/lighting_maps_exercise4.cpp b/src/2.lighting/4.4.lighting_maps_exercise4/lighting_maps_exercise4.cpp index 998f853..f0816b9 100644 --- a/src/2.lighting/4.4.lighting_maps_exercise4/lighting_maps_exercise4.cpp +++ b/src/2.lighting/4.4.lighting_maps_exercise4/lighting_maps_exercise4.cpp @@ -174,7 +174,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -285,8 +285,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -307,7 +310,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/2.lighting/5.1.light_casters_directional/light_casters_directional.cpp b/src/2.lighting/5.1.light_casters_directional/light_casters_directional.cpp index 8609582..fba512f 100644 --- a/src/2.lighting/5.1.light_casters_directional/light_casters_directional.cpp +++ b/src/2.lighting/5.1.light_casters_directional/light_casters_directional.cpp @@ -182,7 +182,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -304,8 +304,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -326,7 +328,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/2.lighting/5.2.light_casters_point/light_casters_point.cpp b/src/2.lighting/5.2.light_casters_point/light_casters_point.cpp index 680a76e..90b529a 100644 --- a/src/2.lighting/5.2.light_casters_point/light_casters_point.cpp +++ b/src/2.lighting/5.2.light_casters_point/light_casters_point.cpp @@ -185,7 +185,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -305,8 +305,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -327,7 +330,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/2.lighting/5.3.light_casters_spot/light_casters_spot.cpp b/src/2.lighting/5.3.light_casters_spot/light_casters_spot.cpp index cbfce0c..47a057d 100644 --- a/src/2.lighting/5.3.light_casters_spot/light_casters_spot.cpp +++ b/src/2.lighting/5.3.light_casters_spot/light_casters_spot.cpp @@ -182,7 +182,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -306,8 +306,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -328,7 +331,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/2.lighting/5.4.light_casters_spot_soft/light_casters_spot_soft.cpp b/src/2.lighting/5.4.light_casters_spot_soft/light_casters_spot_soft.cpp index 0b53102..89195d2 100644 --- a/src/2.lighting/5.4.light_casters_spot_soft/light_casters_spot_soft.cpp +++ b/src/2.lighting/5.4.light_casters_spot_soft/light_casters_spot_soft.cpp @@ -182,7 +182,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -306,8 +306,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -328,7 +331,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/2.lighting/6.multiple_lights/multiple_lights.cpp b/src/2.lighting/6.multiple_lights/multiple_lights.cpp index 77fd3c9..9689bf0 100644 --- a/src/2.lighting/6.multiple_lights/multiple_lights.cpp +++ b/src/2.lighting/6.multiple_lights/multiple_lights.cpp @@ -192,7 +192,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -227,32 +227,32 @@ int main() lightingShader.setVec3("pointLights[0].diffuse", 0.8f, 0.8f, 0.8f); lightingShader.setVec3("pointLights[0].specular", 1.0f, 1.0f, 1.0f); lightingShader.setFloat("pointLights[0].constant", 1.0f); - lightingShader.setFloat("pointLights[0].linear", 0.09); - lightingShader.setFloat("pointLights[0].quadratic", 0.032); + lightingShader.setFloat("pointLights[0].linear", 0.09f); + lightingShader.setFloat("pointLights[0].quadratic", 0.032f); // point light 2 lightingShader.setVec3("pointLights[1].position", pointLightPositions[1]); lightingShader.setVec3("pointLights[1].ambient", 0.05f, 0.05f, 0.05f); lightingShader.setVec3("pointLights[1].diffuse", 0.8f, 0.8f, 0.8f); lightingShader.setVec3("pointLights[1].specular", 1.0f, 1.0f, 1.0f); lightingShader.setFloat("pointLights[1].constant", 1.0f); - lightingShader.setFloat("pointLights[1].linear", 0.09); - lightingShader.setFloat("pointLights[1].quadratic", 0.032); + lightingShader.setFloat("pointLights[1].linear", 0.09f); + lightingShader.setFloat("pointLights[1].quadratic", 0.032f); // point light 3 lightingShader.setVec3("pointLights[2].position", pointLightPositions[2]); lightingShader.setVec3("pointLights[2].ambient", 0.05f, 0.05f, 0.05f); lightingShader.setVec3("pointLights[2].diffuse", 0.8f, 0.8f, 0.8f); lightingShader.setVec3("pointLights[2].specular", 1.0f, 1.0f, 1.0f); lightingShader.setFloat("pointLights[2].constant", 1.0f); - lightingShader.setFloat("pointLights[2].linear", 0.09); - lightingShader.setFloat("pointLights[2].quadratic", 0.032); + lightingShader.setFloat("pointLights[2].linear", 0.09f); + lightingShader.setFloat("pointLights[2].quadratic", 0.032f); // point light 4 lightingShader.setVec3("pointLights[3].position", pointLightPositions[3]); lightingShader.setVec3("pointLights[3].ambient", 0.05f, 0.05f, 0.05f); lightingShader.setVec3("pointLights[3].diffuse", 0.8f, 0.8f, 0.8f); lightingShader.setVec3("pointLights[3].specular", 1.0f, 1.0f, 1.0f); lightingShader.setFloat("pointLights[3].constant", 1.0f); - lightingShader.setFloat("pointLights[3].linear", 0.09); - lightingShader.setFloat("pointLights[3].quadratic", 0.032); + lightingShader.setFloat("pointLights[3].linear", 0.09f); + lightingShader.setFloat("pointLights[3].quadratic", 0.032f); // spotLight lightingShader.setVec3("spotLight.position", camera.Position); lightingShader.setVec3("spotLight.direction", camera.Front); @@ -260,8 +260,8 @@ int main() lightingShader.setVec3("spotLight.diffuse", 1.0f, 1.0f, 1.0f); lightingShader.setVec3("spotLight.specular", 1.0f, 1.0f, 1.0f); lightingShader.setFloat("spotLight.constant", 1.0f); - lightingShader.setFloat("spotLight.linear", 0.09); - lightingShader.setFloat("spotLight.quadratic", 0.032); + lightingShader.setFloat("spotLight.linear", 0.09f); + lightingShader.setFloat("spotLight.quadratic", 0.032f); lightingShader.setFloat("spotLight.cutOff", glm::cos(glm::radians(12.5f))); lightingShader.setFloat("spotLight.outerCutOff", glm::cos(glm::radians(15.0f))); @@ -359,8 +359,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -381,7 +384,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/3.model_loading/1.model_loading/model_loading.cpp b/src/3.model_loading/1.model_loading/model_loading.cpp index 330d118..c66cff8 100644 --- a/src/3.model_loading/1.model_loading/model_loading.cpp +++ b/src/3.model_loading/1.model_loading/model_loading.cpp @@ -94,7 +94,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -164,8 +164,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -186,5 +189,5 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } diff --git a/src/4.advanced_opengl/1.1.depth_testing/depth_testing.cpp b/src/4.advanced_opengl/1.1.depth_testing/depth_testing.cpp index 575a22a..5a94de2 100644 --- a/src/4.advanced_opengl/1.1.depth_testing/depth_testing.cpp +++ b/src/4.advanced_opengl/1.1.depth_testing/depth_testing.cpp @@ -177,7 +177,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -259,8 +259,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -281,7 +284,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/4.advanced_opengl/1.2.depth_testing_view/depth_testing_view.cpp b/src/4.advanced_opengl/1.2.depth_testing_view/depth_testing_view.cpp index a8b47bf..666d508 100644 --- a/src/4.advanced_opengl/1.2.depth_testing_view/depth_testing_view.cpp +++ b/src/4.advanced_opengl/1.2.depth_testing_view/depth_testing_view.cpp @@ -177,7 +177,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -259,8 +259,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -281,7 +284,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/4.advanced_opengl/10.2.asteroids/asteroids.cpp b/src/4.advanced_opengl/10.2.asteroids/asteroids.cpp index d3d7343..0848dd0 100644 --- a/src/4.advanced_opengl/10.2.asteroids/asteroids.cpp +++ b/src/4.advanced_opengl/10.2.asteroids/asteroids.cpp @@ -88,7 +88,7 @@ int main() unsigned int amount = 1000; glm::mat4* modelMatrices; modelMatrices = new glm::mat4[amount]; - srand(glfwGetTime()); // initialize random seed + srand(static_cast(glfwGetTime())); // initialize random seed float radius = 50.0; float offset = 2.5f; for (unsigned int i = 0; i < amount; i++) @@ -105,11 +105,11 @@ int main() model = glm::translate(model, glm::vec3(x, y, z)); // 2. scale: Scale between 0.05 and 0.25f - float scale = (rand() % 20) / 100.0f + 0.05; + float scale = static_cast((rand() % 20) / 100.0 + 0.05); model = glm::scale(model, glm::vec3(scale)); // 3. rotation: add random rotation around a (semi)randomly picked rotation axis vector - float rotAngle = (rand() % 360); + float rotAngle = static_cast((rand() % 360)); model = glm::rotate(model, rotAngle, glm::vec3(0.4f, 0.6f, 0.8f)); // 4. now add to list of matrices @@ -122,7 +122,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -194,8 +194,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -216,5 +219,5 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } diff --git a/src/4.advanced_opengl/10.3.asteroids_instanced/asteroids_instanced.cpp b/src/4.advanced_opengl/10.3.asteroids_instanced/asteroids_instanced.cpp index 45fed0f..1950198 100644 --- a/src/4.advanced_opengl/10.3.asteroids_instanced/asteroids_instanced.cpp +++ b/src/4.advanced_opengl/10.3.asteroids_instanced/asteroids_instanced.cpp @@ -89,7 +89,7 @@ int main() unsigned int amount = 100000; glm::mat4* modelMatrices; modelMatrices = new glm::mat4[amount]; - srand(glfwGetTime()); // initialize random seed + srand(static_cast(glfwGetTime())); // initialize random seed float radius = 150.0; float offset = 25.0f; for (unsigned int i = 0; i < amount; i++) @@ -106,11 +106,11 @@ int main() model = glm::translate(model, glm::vec3(x, y, z)); // 2. scale: Scale between 0.05 and 0.25f - float scale = (rand() % 20) / 100.0f + 0.05; + auto scale = static_cast((rand() % 20) / 100.0 + 0.05); model = glm::scale(model, glm::vec3(scale)); // 3. rotation: add random rotation around a (semi)randomly picked rotation axis vector - float rotAngle = (rand() % 360); + auto rotAngle = static_cast((rand() % 360)); model = glm::rotate(model, rotAngle, glm::vec3(0.4f, 0.6f, 0.8f)); // 4. now add to list of matrices @@ -156,7 +156,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -194,7 +194,7 @@ int main() for (unsigned int i = 0; i < rock.meshes.size(); i++) { glBindVertexArray(rock.meshes[i].VAO); - glDrawElementsInstanced(GL_TRIANGLES, rock.meshes[i].indices.size(), GL_UNSIGNED_INT, 0, amount); + glDrawElementsInstanced(GL_TRIANGLES, static_cast(rock.meshes[i].indices.size()), GL_UNSIGNED_INT, 0, amount); glBindVertexArray(0); } @@ -236,8 +236,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -258,5 +261,5 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } diff --git a/src/4.advanced_opengl/11.1.anti_aliasing_msaa/anti_aliasing_msaa.cpp b/src/4.advanced_opengl/11.1.anti_aliasing_msaa/anti_aliasing_msaa.cpp index 8243bfe..db5854a 100644 --- a/src/4.advanced_opengl/11.1.anti_aliasing_msaa/anti_aliasing_msaa.cpp +++ b/src/4.advanced_opengl/11.1.anti_aliasing_msaa/anti_aliasing_msaa.cpp @@ -141,7 +141,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -202,8 +202,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -224,5 +226,5 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } diff --git a/src/4.advanced_opengl/11.2.anti_aliasing_offscreen/anti_aliasing_offscreen.cpp b/src/4.advanced_opengl/11.2.anti_aliasing_offscreen/anti_aliasing_offscreen.cpp index bcaccaa..0f6d003 100644 --- a/src/4.advanced_opengl/11.2.anti_aliasing_offscreen/anti_aliasing_offscreen.cpp +++ b/src/4.advanced_opengl/11.2.anti_aliasing_offscreen/anti_aliasing_offscreen.cpp @@ -209,7 +209,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -294,8 +294,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -316,5 +318,5 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } diff --git a/src/4.advanced_opengl/2.stencil_testing/stencil_testing.cpp b/src/4.advanced_opengl/2.stencil_testing/stencil_testing.cpp index 5cfd90e..805e12d 100644 --- a/src/4.advanced_opengl/2.stencil_testing/stencil_testing.cpp +++ b/src/4.advanced_opengl/2.stencil_testing/stencil_testing.cpp @@ -181,7 +181,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -239,7 +239,7 @@ int main() glStencilMask(0x00); glDisable(GL_DEPTH_TEST); shaderSingleColor.use(); - float scale = 1.1; + float scale = 1.1f; // cubes glBindVertexArray(cubeVAO); glBindTexture(GL_TEXTURE_2D, cubeTexture); @@ -303,8 +303,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -325,7 +328,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/4.advanced_opengl/3.1.blending_discard/blending_discard.cpp b/src/4.advanced_opengl/3.1.blending_discard/blending_discard.cpp index 160f28d..9dbd2c0 100644 --- a/src/4.advanced_opengl/3.1.blending_discard/blending_discard.cpp +++ b/src/4.advanced_opengl/3.1.blending_discard/blending_discard.cpp @@ -208,7 +208,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -302,8 +302,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -324,7 +326,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/4.advanced_opengl/3.2.blending_sort/blending_sorted.cpp b/src/4.advanced_opengl/3.2.blending_sort/blending_sorted.cpp index 1f1d880..a8b5c0b 100644 --- a/src/4.advanced_opengl/3.2.blending_sort/blending_sorted.cpp +++ b/src/4.advanced_opengl/3.2.blending_sort/blending_sorted.cpp @@ -210,7 +210,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -313,8 +313,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -335,7 +337,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/4.advanced_opengl/5.1.framebuffers/framebuffers.cpp b/src/4.advanced_opengl/5.1.framebuffers/framebuffers.cpp index 8b187cf..3aa9b7c 100644 --- a/src/4.advanced_opengl/5.1.framebuffers/framebuffers.cpp +++ b/src/4.advanced_opengl/5.1.framebuffers/framebuffers.cpp @@ -226,7 +226,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -329,8 +329,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -351,7 +353,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/4.advanced_opengl/5.2.framebuffers_exercise1/framebuffers_exercise1.cpp b/src/4.advanced_opengl/5.2.framebuffers_exercise1/framebuffers_exercise1.cpp index c6d30d5..85c71c7 100644 --- a/src/4.advanced_opengl/5.2.framebuffers_exercise1/framebuffers_exercise1.cpp +++ b/src/4.advanced_opengl/5.2.framebuffers_exercise1/framebuffers_exercise1.cpp @@ -226,7 +226,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -361,8 +361,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -383,7 +385,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/4.advanced_opengl/6.1.cubemaps_skybox/cubemaps_skybox.cpp b/src/4.advanced_opengl/6.1.cubemaps_skybox/cubemaps_skybox.cpp index 0e88d9a..9b0ae08 100644 --- a/src/4.advanced_opengl/6.1.cubemaps_skybox/cubemaps_skybox.cpp +++ b/src/4.advanced_opengl/6.1.cubemaps_skybox/cubemaps_skybox.cpp @@ -222,7 +222,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -309,8 +309,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -331,7 +333,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/4.advanced_opengl/6.2.cubemaps_environment_mapping/cubemaps_environment_mapping.cpp b/src/4.advanced_opengl/6.2.cubemaps_environment_mapping/cubemaps_environment_mapping.cpp index 24a1a49..8c0ca0a 100644 --- a/src/4.advanced_opengl/6.2.cubemaps_environment_mapping/cubemaps_environment_mapping.cpp +++ b/src/4.advanced_opengl/6.2.cubemaps_environment_mapping/cubemaps_environment_mapping.cpp @@ -220,7 +220,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + float currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -308,8 +308,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -330,7 +332,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/4.advanced_opengl/8.advanced_glsl_ubo/advanced_glsl_ubo.cpp b/src/4.advanced_opengl/8.advanced_glsl_ubo/advanced_glsl_ubo.cpp index 4d90e6d..dce90ea 100644 --- a/src/4.advanced_opengl/8.advanced_glsl_ubo/advanced_glsl_ubo.cpp +++ b/src/4.advanced_opengl/8.advanced_glsl_ubo/advanced_glsl_ubo.cpp @@ -168,7 +168,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -257,8 +257,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; diff --git a/src/4.advanced_opengl/9.2.geometry_shader_exploding/geometry_shader_exploding.cpp b/src/4.advanced_opengl/9.2.geometry_shader_exploding/geometry_shader_exploding.cpp index 76f474c..95fe367 100644 --- a/src/4.advanced_opengl/9.2.geometry_shader_exploding/geometry_shader_exploding.cpp +++ b/src/4.advanced_opengl/9.2.geometry_shader_exploding/geometry_shader_exploding.cpp @@ -88,7 +88,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -111,7 +111,7 @@ int main() shader.setMat4("model", model); // add time component to geometry shader in the form of a uniform - shader.setFloat("time", glfwGetTime()); + shader.setFloat("time", static_cast(glfwGetTime())); // draw model nanosuit.Draw(shader); @@ -154,8 +154,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -176,5 +178,5 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } diff --git a/src/4.advanced_opengl/9.3.geometry_shader_normals/normal_visualization.cpp b/src/4.advanced_opengl/9.3.geometry_shader_normals/normal_visualization.cpp index 104f1db..cca63bc 100644 --- a/src/4.advanced_opengl/9.3.geometry_shader_normals/normal_visualization.cpp +++ b/src/4.advanced_opengl/9.3.geometry_shader_normals/normal_visualization.cpp @@ -90,7 +90,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -161,8 +161,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -183,5 +185,5 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } diff --git a/src/5.advanced_lighting/1.advanced_lighting/advanced_lighting.cpp b/src/5.advanced_lighting/1.advanced_lighting/advanced_lighting.cpp index 05d1c88..d456294 100644 --- a/src/5.advanced_lighting/1.advanced_lighting/advanced_lighting.cpp +++ b/src/5.advanced_lighting/1.advanced_lighting/advanced_lighting.cpp @@ -129,7 +129,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -213,8 +213,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -235,7 +237,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/5.advanced_lighting/2.gamma_correction/gamma_correction.cpp b/src/5.advanced_lighting/2.gamma_correction/gamma_correction.cpp index f792ac4..9a61383 100644 --- a/src/5.advanced_lighting/2.gamma_correction/gamma_correction.cpp +++ b/src/5.advanced_lighting/2.gamma_correction/gamma_correction.cpp @@ -141,7 +141,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -226,8 +226,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -248,7 +250,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/5.advanced_lighting/3.1.1.shadow_mapping_depth/shadow_mapping_depth.cpp b/src/5.advanced_lighting/3.1.1.shadow_mapping_depth/shadow_mapping_depth.cpp index 5e74679..a8886fc 100644 --- a/src/5.advanced_lighting/3.1.1.shadow_mapping_depth/shadow_mapping_depth.cpp +++ b/src/5.advanced_lighting/3.1.1.shadow_mapping_depth/shadow_mapping_depth.cpp @@ -154,7 +154,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -378,8 +378,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -400,7 +403,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/5.advanced_lighting/3.1.2.shadow_mapping_base/shadow_mapping_base.cpp b/src/5.advanced_lighting/3.1.2.shadow_mapping_base/shadow_mapping_base.cpp index 80cf117..6aaa8f7 100644 --- a/src/5.advanced_lighting/3.1.2.shadow_mapping_base/shadow_mapping_base.cpp +++ b/src/5.advanced_lighting/3.1.2.shadow_mapping_base/shadow_mapping_base.cpp @@ -158,7 +158,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -402,8 +402,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -424,7 +426,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/5.advanced_lighting/3.1.3.shadow_mapping/shadow_mapping.cpp b/src/5.advanced_lighting/3.1.3.shadow_mapping/shadow_mapping.cpp index 8bae330..cdd1150 100644 --- a/src/5.advanced_lighting/3.1.3.shadow_mapping/shadow_mapping.cpp +++ b/src/5.advanced_lighting/3.1.3.shadow_mapping/shadow_mapping.cpp @@ -160,7 +160,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -409,8 +409,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -431,7 +433,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/5.advanced_lighting/3.2.1.point_shadows/point_shadows.cpp b/src/5.advanced_lighting/3.2.1.point_shadows/point_shadows.cpp index 6996e24..dcc5fd9 100644 --- a/src/5.advanced_lighting/3.2.1.point_shadows/point_shadows.cpp +++ b/src/5.advanced_lighting/3.2.1.point_shadows/point_shadows.cpp @@ -129,7 +129,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -138,7 +138,7 @@ int main() processInput(window); // move light position over time - lightPos.z = sin(glfwGetTime() * 0.5) * 3.0; + lightPos.z = static_cast(sin(glfwGetTime() * 0.5) * 3.0); // render // ------ @@ -356,8 +356,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -378,7 +380,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/5.advanced_lighting/3.2.2.point_shadows_soft/point_shadows_soft.cpp b/src/5.advanced_lighting/3.2.2.point_shadows_soft/point_shadows_soft.cpp index a789d16..88ec9a4 100644 --- a/src/5.advanced_lighting/3.2.2.point_shadows_soft/point_shadows_soft.cpp +++ b/src/5.advanced_lighting/3.2.2.point_shadows_soft/point_shadows_soft.cpp @@ -129,7 +129,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -138,7 +138,7 @@ int main() processInput(window); // move light position over time - lightPos.z = sin(glfwGetTime() * 0.5) * 3.0; + lightPos.z = static_cast(sin(glfwGetTime() * 0.5) * 3.0); // render // ------ @@ -356,8 +356,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -378,7 +380,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/5.advanced_lighting/4.normal_mapping/normal_mapping.cpp b/src/5.advanced_lighting/4.normal_mapping/normal_mapping.cpp index 583c9a8..a689077 100644 --- a/src/5.advanced_lighting/4.normal_mapping/normal_mapping.cpp +++ b/src/5.advanced_lighting/4.normal_mapping/normal_mapping.cpp @@ -101,7 +101,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -269,8 +269,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -291,7 +293,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/5.advanced_lighting/5.1.parallax_mapping/parallax_mapping.cpp b/src/5.advanced_lighting/5.1.parallax_mapping/parallax_mapping.cpp index 1ae27d6..09b1078 100644 --- a/src/5.advanced_lighting/5.1.parallax_mapping/parallax_mapping.cpp +++ b/src/5.advanced_lighting/5.1.parallax_mapping/parallax_mapping.cpp @@ -23,7 +23,7 @@ void renderQuad(); // settings const unsigned int SCR_WIDTH = 800; const unsigned int SCR_HEIGHT = 600; -float heightScale = 0.1; +float heightScale = 0.1f; // camera Camera camera(glm::vec3(0.0f, 0.0f, 3.0f)); @@ -107,7 +107,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -298,8 +298,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -320,7 +322,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/5.advanced_lighting/5.2.steep_parallax_mapping/steep_parallax_mapping.cpp b/src/5.advanced_lighting/5.2.steep_parallax_mapping/steep_parallax_mapping.cpp index 108fe92..72970f9 100644 --- a/src/5.advanced_lighting/5.2.steep_parallax_mapping/steep_parallax_mapping.cpp +++ b/src/5.advanced_lighting/5.2.steep_parallax_mapping/steep_parallax_mapping.cpp @@ -23,7 +23,7 @@ void renderQuad(); // settings const unsigned int SCR_WIDTH = 800; const unsigned int SCR_HEIGHT = 600; -float heightScale = 0.1; +float heightScale = 0.1f; // camera Camera camera(glm::vec3(0.0f, 0.0f, 3.0f)); @@ -107,7 +107,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -298,8 +298,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -320,7 +322,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/5.advanced_lighting/5.3.parallax_occlusion_mapping/parallax_occlusion_mapping.cpp b/src/5.advanced_lighting/5.3.parallax_occlusion_mapping/parallax_occlusion_mapping.cpp index 25280dd..43f5708 100644 --- a/src/5.advanced_lighting/5.3.parallax_occlusion_mapping/parallax_occlusion_mapping.cpp +++ b/src/5.advanced_lighting/5.3.parallax_occlusion_mapping/parallax_occlusion_mapping.cpp @@ -23,7 +23,7 @@ void renderQuad(); // settings const unsigned int SCR_WIDTH = 800; const unsigned int SCR_HEIGHT = 600; -float heightScale = 0.1; +float heightScale = 0.1f; // camera Camera camera(glm::vec3(0.0f, 0.0f, 3.0f)); @@ -107,7 +107,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -298,8 +298,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -320,7 +322,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/5.advanced_lighting/6.hdr/hdr.cpp b/src/5.advanced_lighting/6.hdr/hdr.cpp index b5ab168..e48ca83 100644 --- a/src/5.advanced_lighting/6.hdr/hdr.cpp +++ b/src/5.advanced_lighting/6.hdr/hdr.cpp @@ -141,7 +141,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -359,8 +359,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -381,7 +383,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/5.advanced_lighting/7.bloom/bloom.cpp b/src/5.advanced_lighting/7.bloom/bloom.cpp index 24d7e47..5e1132b 100644 --- a/src/5.advanced_lighting/7.bloom/bloom.cpp +++ b/src/5.advanced_lighting/7.bloom/bloom.cpp @@ -177,7 +177,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -467,8 +467,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -489,7 +491,7 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // utility function for loading a 2D texture from file diff --git a/src/5.advanced_lighting/8.1.deferred_shading/deferred_shading.cpp b/src/5.advanced_lighting/8.1.deferred_shading/deferred_shading.cpp index 8b18b54..cc37ef4 100644 --- a/src/5.advanced_lighting/8.1.deferred_shading/deferred_shading.cpp +++ b/src/5.advanced_lighting/8.1.deferred_shading/deferred_shading.cpp @@ -150,14 +150,14 @@ int main() for (unsigned int i = 0; i < NR_LIGHTS; i++) { // calculate slightly random offsets - float xPos = ((rand() % 100) / 100.0) * 6.0 - 3.0; - float yPos = ((rand() % 100) / 100.0) * 6.0 - 4.0; - float zPos = ((rand() % 100) / 100.0) * 6.0 - 3.0; + float xPos = static_cast(((rand() % 100) / 100.0) * 6.0 - 3.0); + float yPos = static_cast(((rand() % 100) / 100.0) * 6.0 - 4.0); + float zPos = static_cast(((rand() % 100) / 100.0) * 6.0 - 3.0); lightPositions.push_back(glm::vec3(xPos, yPos, zPos)); // also calculate random color - float rColor = ((rand() % 100) / 200.0f) + 0.5; // between 0.5 and 1.0 - float gColor = ((rand() % 100) / 200.0f) + 0.5; // between 0.5 and 1.0 - float bColor = ((rand() % 100) / 200.0f) + 0.5; // between 0.5 and 1.0 + float rColor = static_cast(((rand() % 100) / 200.0f) + 0.5); // between 0.5 and 1.0 + float gColor = static_cast(((rand() % 100) / 200.0f) + 0.5); // between 0.5 and 1.0 + float bColor = static_cast(((rand() % 100) / 200.0f) + 0.5); // between 0.5 and 1.0 lightColors.push_back(glm::vec3(rColor, gColor, bColor)); } @@ -174,7 +174,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -223,8 +223,8 @@ int main() shaderLightingPass.setVec3("lights[" + std::to_string(i) + "].Position", lightPositions[i]); shaderLightingPass.setVec3("lights[" + std::to_string(i) + "].Color", lightColors[i]); // update attenuation parameters and calculate radius - const float linear = 0.7; - const float quadratic = 1.8; + const float linear = 0.7f; + const float quadratic = 1.8f; shaderLightingPass.setFloat("lights[" + std::to_string(i) + "].Linear", linear); shaderLightingPass.setFloat("lights[" + std::to_string(i) + "].Quadratic", quadratic); } @@ -403,8 +403,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -425,5 +427,5 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } diff --git a/src/5.advanced_lighting/8.2.deferred_shading_volumes/deferred_shading_volumes.cpp b/src/5.advanced_lighting/8.2.deferred_shading_volumes/deferred_shading_volumes.cpp index c932861..1a2b986 100644 --- a/src/5.advanced_lighting/8.2.deferred_shading_volumes/deferred_shading_volumes.cpp +++ b/src/5.advanced_lighting/8.2.deferred_shading_volumes/deferred_shading_volumes.cpp @@ -150,14 +150,14 @@ int main() for (unsigned int i = 0; i < NR_LIGHTS; i++) { // calculate slightly random offsets - float xPos = ((rand() % 100) / 100.0) * 6.0 - 3.0; - float yPos = ((rand() % 100) / 100.0) * 6.0 - 4.0; - float zPos = ((rand() % 100) / 100.0) * 6.0 - 3.0; + float xPos = static_cast(((rand() % 100) / 100.0) * 6.0 - 3.0); + float yPos = static_cast(((rand() % 100) / 100.0) * 6.0 - 4.0); + float zPos = static_cast(((rand() % 100) / 100.0) * 6.0 - 3.0); lightPositions.push_back(glm::vec3(xPos, yPos, zPos)); // also calculate random color - float rColor = ((rand() % 100) / 200.0f) + 0.5; // between 0.5 and 1.0 - float gColor = ((rand() % 100) / 200.0f) + 0.5; // between 0.5 and 1.0 - float bColor = ((rand() % 100) / 200.0f) + 0.5; // between 0.5 and 1.0 + float rColor = static_cast(((rand() % 100) / 200.0f) + 0.5); // between 0.5 and 1.) + float gColor = static_cast(((rand() % 100) / 200.0f) + 0.5); // between 0.5 and 1.) + float bColor = static_cast(((rand() % 100) / 200.0f) + 0.5); // between 0.5 and 1.) lightColors.push_back(glm::vec3(rColor, gColor, bColor)); } @@ -174,7 +174,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -223,9 +223,9 @@ int main() shaderLightingPass.setVec3("lights[" + std::to_string(i) + "].Position", lightPositions[i]); shaderLightingPass.setVec3("lights[" + std::to_string(i) + "].Color", lightColors[i]); // update attenuation parameters and calculate radius - const float constant = 1.0; // note that we don't send this to the shader, we assume it is always 1.0 (in our case) - const float linear = 0.7; - const float quadratic = 1.8; + const float constant = 1.0f; // note that we don't send this to the shader, we assume it is always 1.0 (in our case) + const float linear = 0.7f; + const float quadratic = 1.8f; shaderLightingPass.setFloat("lights[" + std::to_string(i) + "].Linear", linear); shaderLightingPass.setFloat("lights[" + std::to_string(i) + "].Quadratic", quadratic); // then calculate radius of light volume/sphere @@ -408,8 +408,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -430,5 +432,5 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } diff --git a/src/5.advanced_lighting/9.ssao/ssao.cpp b/src/5.advanced_lighting/9.ssao/ssao.cpp index 6f32510..ac7920d 100644 --- a/src/5.advanced_lighting/9.ssao/ssao.cpp +++ b/src/5.advanced_lighting/9.ssao/ssao.cpp @@ -173,7 +173,7 @@ int main() glm::vec3 sample(randomFloats(generator) * 2.0 - 1.0, randomFloats(generator) * 2.0 - 1.0, randomFloats(generator)); sample = glm::normalize(sample); sample *= randomFloats(generator); - float scale = float(i) / 64.0; + float scale = float(i) / 64.0f; // scale samples s.t. they're more aligned to center of kernel scale = lerp(0.1f, 1.0f, scale * scale); @@ -222,7 +222,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -302,8 +302,8 @@ int main() shaderLightingPass.setVec3("light.Position", lightPosView); shaderLightingPass.setVec3("light.Color", lightColor); // Update attenuation parameters - const float linear = 0.09; - const float quadratic = 0.032; + const float linear = 0.09f; + const float quadratic = 0.032f; shaderLightingPass.setFloat("light.Linear", linear); shaderLightingPass.setFloat("light.Quadratic", quadratic); glActiveTexture(GL_TEXTURE0); @@ -462,8 +462,10 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); if (firstMouse) { lastX = xpos; @@ -484,5 +486,5 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } diff --git a/src/6.pbr/1.1.lighting/lighting.cpp b/src/6.pbr/1.1.lighting/lighting.cpp index a749a61..9259500 100644 --- a/src/6.pbr/1.1.lighting/lighting.cpp +++ b/src/6.pbr/1.1.lighting/lighting.cpp @@ -115,7 +115,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -213,8 +213,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -235,13 +238,13 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // renders (and builds at first invocation) a sphere // ------------------------------------------------- unsigned int sphereVAO = 0; -unsigned int indexCount; +GLsizei indexCount; void renderSphere() { if (sphereVAO == 0) @@ -259,7 +262,7 @@ void renderSphere() const unsigned int X_SEGMENTS = 64; const unsigned int Y_SEGMENTS = 64; - const float PI = 3.14159265359; + const float PI = 3.14159265359f; for (unsigned int x = 0; x <= X_SEGMENTS; ++x) { for (unsigned int y = 0; y <= Y_SEGMENTS; ++y) @@ -297,7 +300,7 @@ void renderSphere() } oddRow = !oddRow; } - indexCount = indices.size(); + indexCount = static_cast(indices.size()); std::vector data; for (unsigned int i = 0; i < positions.size(); ++i) diff --git a/src/6.pbr/1.2.lighting_textured/lighting_textured.cpp b/src/6.pbr/1.2.lighting_textured/lighting_textured.cpp index 0424ec0..e0bbd56 100644 --- a/src/6.pbr/1.2.lighting_textured/lighting_textured.cpp +++ b/src/6.pbr/1.2.lighting_textured/lighting_textured.cpp @@ -120,7 +120,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -224,8 +224,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -246,13 +249,13 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // renders (and builds at first invocation) a sphere // ------------------------------------------------- unsigned int sphereVAO = 0; -unsigned int indexCount; +GLsizei indexCount; void renderSphere() { if (sphereVAO == 0) @@ -270,7 +273,7 @@ void renderSphere() const unsigned int X_SEGMENTS = 64; const unsigned int Y_SEGMENTS = 64; - const float PI = 3.14159265359; + const float PI = 3.14159265359f; for (unsigned int x = 0; x <= X_SEGMENTS; ++x) { for (unsigned int y = 0; y <= Y_SEGMENTS; ++y) @@ -308,7 +311,7 @@ void renderSphere() } oddRow = !oddRow; } - indexCount = indices.size(); + indexCount = static_cast(indices.size()); std::vector data; for (unsigned int i = 0; i < positions.size(); ++i) diff --git a/src/6.pbr/2.1.1.ibl_irradiance_conversion/ibl_irradiance_conversion.cpp b/src/6.pbr/2.1.1.ibl_irradiance_conversion/ibl_irradiance_conversion.cpp index bf704ac..097867b 100644 --- a/src/6.pbr/2.1.1.ibl_irradiance_conversion/ibl_irradiance_conversion.cpp +++ b/src/6.pbr/2.1.1.ibl_irradiance_conversion/ibl_irradiance_conversion.cpp @@ -214,7 +214,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -329,8 +329,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -351,13 +354,13 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // renders (and builds at first invocation) a sphere // ------------------------------------------------- unsigned int sphereVAO = 0; -unsigned int indexCount; +GLsizei indexCount; void renderSphere() { if (sphereVAO == 0) @@ -375,7 +378,7 @@ void renderSphere() const unsigned int X_SEGMENTS = 64; const unsigned int Y_SEGMENTS = 64; - const float PI = 3.14159265359; + const float PI = 3.14159265359f; for (unsigned int x = 0; x <= X_SEGMENTS; ++x) { for (unsigned int y = 0; y <= Y_SEGMENTS; ++y) @@ -413,7 +416,7 @@ void renderSphere() } oddRow = !oddRow; } - indexCount = indices.size(); + indexCount = static_cast(indices.size()); std::vector data; for (unsigned int i = 0; i < positions.size(); ++i) diff --git a/src/6.pbr/2.1.2.ibl_irradiance/ibl_irradiance.cpp b/src/6.pbr/2.1.2.ibl_irradiance/ibl_irradiance.cpp index 0b1d269..80060a5 100644 --- a/src/6.pbr/2.1.2.ibl_irradiance/ibl_irradiance.cpp +++ b/src/6.pbr/2.1.2.ibl_irradiance/ibl_irradiance.cpp @@ -255,7 +255,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -369,8 +369,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -391,13 +394,13 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // renders (and builds at first invocation) a sphere // ------------------------------------------------- unsigned int sphereVAO = 0; -unsigned int indexCount; +GLsizei indexCount; void renderSphere() { if (sphereVAO == 0) @@ -415,7 +418,7 @@ void renderSphere() const unsigned int X_SEGMENTS = 64; const unsigned int Y_SEGMENTS = 64; - const float PI = 3.14159265359; + const float PI = 3.14159265359f; for (unsigned int x = 0; x <= X_SEGMENTS; ++x) { for (unsigned int y = 0; y <= Y_SEGMENTS; ++y) @@ -453,7 +456,7 @@ void renderSphere() } oddRow = !oddRow; } - indexCount = indices.size(); + indexCount = static_cast(indices.size()); std::vector data; for (unsigned int i = 0; i < positions.size(); ++i) diff --git a/src/6.pbr/2.2.1.ibl_specular/ibl_specular.cpp b/src/6.pbr/2.2.1.ibl_specular/ibl_specular.cpp index 00816b3..fa543af 100644 --- a/src/6.pbr/2.2.1.ibl_specular/ibl_specular.cpp +++ b/src/6.pbr/2.2.1.ibl_specular/ibl_specular.cpp @@ -277,8 +277,8 @@ int main() for (unsigned int mip = 0; mip < maxMipLevels; ++mip) { // reisze framebuffer according to mip-level size. - unsigned int mipWidth = 128 * std::pow(0.5, mip); - unsigned int mipHeight = 128 * std::pow(0.5, mip); + unsigned int mipWidth = static_cast(128 * std::pow(0.5, mip)); + unsigned int mipHeight = static_cast(128 * std::pow(0.5, mip)); glBindRenderbuffer(GL_RENDERBUFFER, captureRBO); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, mipWidth, mipHeight); glViewport(0, 0, mipWidth, mipHeight); @@ -343,7 +343,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -467,8 +467,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -489,13 +492,13 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // renders (and builds at first invocation) a sphere // ------------------------------------------------- unsigned int sphereVAO = 0; -unsigned int indexCount; +GLsizei indexCount; void renderSphere() { if (sphereVAO == 0) @@ -513,7 +516,7 @@ void renderSphere() const unsigned int X_SEGMENTS = 64; const unsigned int Y_SEGMENTS = 64; - const float PI = 3.14159265359; + const float PI = 3.14159265359f; for (unsigned int x = 0; x <= X_SEGMENTS; ++x) { for (unsigned int y = 0; y <= Y_SEGMENTS; ++y) @@ -551,7 +554,7 @@ void renderSphere() } oddRow = !oddRow; } - indexCount = indices.size(); + indexCount = static_cast(indices.size()); std::vector data; for (unsigned int i = 0; i < positions.size(); ++i) diff --git a/src/6.pbr/2.2.2.ibl_specular_textured/ibl_specular_textured.cpp b/src/6.pbr/2.2.2.ibl_specular_textured/ibl_specular_textured.cpp index 002d740..23c1bf4 100644 --- a/src/6.pbr/2.2.2.ibl_specular_textured/ibl_specular_textured.cpp +++ b/src/6.pbr/2.2.2.ibl_specular_textured/ibl_specular_textured.cpp @@ -314,8 +314,8 @@ int main() for (unsigned int mip = 0; mip < maxMipLevels; ++mip) { // reisze framebuffer according to mip-level size. - unsigned int mipWidth = 128 * std::pow(0.5, mip); - unsigned int mipHeight = 128 * std::pow(0.5, mip); + unsigned int mipWidth = static_cast(128 * std::pow(0.5, mip)); + unsigned int mipHeight = static_cast(128 * std::pow(0.5, mip)); glBindRenderbuffer(GL_RENDERBUFFER, captureRBO); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, mipWidth, mipHeight); glViewport(0, 0, mipWidth, mipHeight); @@ -380,7 +380,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + auto currentFrame = static_cast(glfwGetTime()); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; @@ -567,8 +567,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) // glfw: whenever the mouse moves, this callback is called // ------------------------------------------------------- -void mouse_callback(GLFWwindow* window, double xpos, double ypos) +void mouse_callback(GLFWwindow* window, double xposIn, double yposIn) { + auto xpos = static_cast(xposIn); + auto ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -589,13 +592,13 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) // ---------------------------------------------------------------------- void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - camera.ProcessMouseScroll(yoffset); + camera.ProcessMouseScroll(static_cast(yoffset)); } // renders (and builds at first invocation) a sphere // ------------------------------------------------- unsigned int sphereVAO = 0; -unsigned int indexCount; +GLsizei indexCount; void renderSphere() { if (sphereVAO == 0) @@ -613,7 +616,7 @@ void renderSphere() const unsigned int X_SEGMENTS = 64; const unsigned int Y_SEGMENTS = 64; - const float PI = 3.14159265359; + const float PI = 3.14159265359f; for (unsigned int x = 0; x <= X_SEGMENTS; ++x) { for (unsigned int y = 0; y <= Y_SEGMENTS; ++y) @@ -651,7 +654,7 @@ void renderSphere() } oddRow = !oddRow; } - indexCount = indices.size(); + indexCount = static_cast(indices.size()); std::vector data; for (unsigned int i = 0; i < positions.size(); ++i)