diff --git a/CMakeLists.txt b/CMakeLists.txt index df20636..9efbc39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,10 @@ cmake_policy(VERSION 3.0) project (LearnOpenGL) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS ON) + IF(NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build (Debug or Release)" FORCE) ENDIF(NOT CMAKE_BUILD_TYPE) @@ -15,8 +19,6 @@ endif(WIN32) link_directories(${CMAKE_SOURCE_DIR}/lib) -list(APPEND CMAKE_CXX_FLAGS "-std=c++11") - # find the required packages find_package(GLM REQUIRED) message(STATUS "GLM included at ${GLM_INCLUDE_DIR}") @@ -31,6 +33,7 @@ message(STATUS "Found ASSIMP in ${ASSIMP_INCLUDE_DIR}") if(WIN32) set(LIBS glfw3 opengl32 assimp freetype irrKlang) + add_definitions(-D_CRT_SECURE_NO_WARNINGS) elseif(UNIX AND NOT APPLE) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall") find_package(OpenGL REQUIRED) @@ -195,6 +198,9 @@ foreach(CHAPTER ${CHAPTERS}) set(NAME "${CHAPTER}__${DEMO}") add_executable(${NAME} ${SOURCE}) target_link_libraries(${NAME} ${LIBS}) + if(MSVC) + target_link_options(${NAME} PUBLIC /ignore:4099) + endif(MSVC) if(WIN32) set_target_properties(${NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/${CHAPTER}") set_target_properties(${NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/${CHAPTER}/Debug") diff --git a/README.md b/README.md index b0153cd..f90d93c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Keep in mind the supplied libraries were generated with a specific compiler vers ## Linux building First make sure you have CMake, Git, and GCC by typing as root (sudo) `apt-get install g++ cmake git` and then get the required packages: -Using root (sudo) and type `apt-get install libsoil-dev libglm-dev libassimp-dev libglew-dev libglfw3-dev libxinerama-dev libxcursor-dev libxi-dev` . +Using root (sudo) and type `apt-get install libsoil-dev libglm-dev libassimp-dev libglew-dev libglfw3-dev libxinerama-dev libxcursor-dev libxi-dev libfreetype-dev libgl1-mesa-dev xorg-dev` . Next, run CMake (preferably CMake-gui). The source directory is LearnOpenGL and specify the build directory as LearnOpenGL/build. Creating the build directory within LearnOpenGL is important for linking to the resource files (it also will be ignored by Git). Hit configure and specify your compiler files (Unix Makefiles are recommended), resolve any missing directories or libraries, and then hit generate. Navigate to the build directory (`cd LearnOpenGL/build`) and type `make` in the terminal. This should generate the executables in the respective chapter folders. Note that CodeBlocks or other IDEs may have issues running the programs due to problems finding the shader and resource files, however it should still be able to generate the exectuables. To work around this problem it is possible to set an environment variable to tell the tutorials where the resource files can be found. The environment variable is named LOGL_ROOT_PATH and may be set to the path to the root of the LearnOpenGL directory tree. For example: diff --git a/includes/learnopengl/mesh.h b/includes/learnopengl/mesh.h index 36943a3..803f489 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/includes/learnopengl/shader.h b/includes/learnopengl/shader.h index a60870f..1ac9dbe 100644 --- a/includes/learnopengl/shader.h +++ b/includes/learnopengl/shader.h @@ -55,7 +55,7 @@ public: } catch (std::ifstream::failure& e) { - std::cout << "ERROR::SHADER::FILE_NOT_SUCCESFULLY_READ" << std::endl; + std::cout << "ERROR::SHADER::FILE_NOT_SUCCESFULLY_READ: " << e.what() << std::endl; } const char* vShaderCode = vertexCode.c_str(); const char * fShaderCode = fragmentCode.c_str(); diff --git a/includes/learnopengl/shader_m.h b/includes/learnopengl/shader_m.h index c321ec1..b554064 100644 --- a/includes/learnopengl/shader_m.h +++ b/includes/learnopengl/shader_m.h @@ -43,7 +43,7 @@ public: } catch (std::ifstream::failure& e) { - std::cout << "ERROR::SHADER::FILE_NOT_SUCCESFULLY_READ" << std::endl; + std::cout << "ERROR::SHADER::FILE_NOT_SUCCESFULLY_READ: " << e.what() << std::endl; } const char* vShaderCode = vertexCode.c_str(); const char * fShaderCode = fragmentCode.c_str(); diff --git a/includes/learnopengl/shader_s.h b/includes/learnopengl/shader_s.h index 484e0ec..80565a8 100644 --- a/includes/learnopengl/shader_s.h +++ b/includes/learnopengl/shader_s.h @@ -42,7 +42,7 @@ public: } catch (std::ifstream::failure& e) { - std::cout << "ERROR::SHADER::FILE_NOT_SUCCESFULLY_READ" << std::endl; + std::cout << "ERROR::SHADER::FILE_NOT_SUCCESFULLY_READ: " << e.what() << std::endl; } const char* vShaderCode = vertexCode.c_str(); const char * fShaderCode = fragmentCode.c_str(); 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..afaafde 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; + double timeValue = glfwGetTime(); + float 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..de32483 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()); + float 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..1b79f31 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; + float camX = static_cast(sin(glfwGetTime()) * radius); + float 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..45c6fc9 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(); + float 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; + float 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..6d556fa 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(); + float 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; + float 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) { + float xpos = static_cast(xposIn); + float 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..93d60ce 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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); -} \ No newline at end of file + camera.ProcessMouseScroll(static_cast(yoffset)); +} diff --git a/src/2.lighting/1.colors/colors.cpp b/src/2.lighting/1.colors/colors.cpp index 92f3fa9..0597909 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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); -} \ No newline at end of file + camera.ProcessMouseScroll(static_cast(yoffset)); +} 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..99a1f71 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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); -} \ No newline at end of file + camera.ProcessMouseScroll(static_cast(yoffset)); +} 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..ffe2342 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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); -} \ No newline at end of file + camera.ProcessMouseScroll(static_cast(yoffset)); +} diff --git a/src/2.lighting/3.1.materials/materials.cpp b/src/2.lighting/3.1.materials/materials.cpp index 5ec0f53..82de7e1 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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); -} \ No newline at end of file + camera.ProcessMouseScroll(static_cast(yoffset)); +} 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..7b1c0b0 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..4f4b412 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..a7f04e8 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..dc0d755 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..5655313 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..7d65b24 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..6503df9 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..416943e 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..6a7c73c 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..bc41ef8 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..a7c7210 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..d6b4ad0 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..fa34d68 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..1eeca2c 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; + 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 @@ -156,7 +156,7 @@ int main() { // per-frame time logic // -------------------- - float currentFrame = glfwGetTime(); + float 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) { + float xpos = static_cast(xposIn); + float 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..8c1eb38 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..6056bbc 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..9176e73 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..0d8d7be 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..1fbb1c1 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..9f39226 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..16f43aa 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..88a8def 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..8ca9ddc 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) { + float xpos = static_cast(xposIn); + float 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..9d5f74d 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..f735cff 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..4a968cf 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..3227425 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..44d93a6 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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 4d08854..91d2aeb 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..5873ca8 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..a201fa9 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..387becb 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..2a51384 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..14326db 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..db8882a 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..958dbfa 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..e2439d0 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..0f63afe 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..a8b6527 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..13d6e10 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) { + float xpos = static_cast(xposIn); + float 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..68692f2 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) { + float xpos = static_cast(xposIn); + float 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..08ac98e 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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..e24f8c9 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(); + float 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) { + float xpos = static_cast(xposIn); + float ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -235,7 +238,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)); } // renders (and builds at first invocation) a sphere @@ -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..b64b00f 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(); + float 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) { + float xpos = static_cast(xposIn); + float ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -246,7 +249,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)); } // renders (and builds at first invocation) a sphere @@ -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..de2ce95 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(); + float 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) { + float xpos = static_cast(xposIn); + float ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -351,7 +354,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)); } // renders (and builds at first invocation) a sphere @@ -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..38cf5a4 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(); + float 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) { + float xpos = static_cast(xposIn); + float ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -391,7 +394,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)); } // renders (and builds at first invocation) a sphere @@ -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..1e5f62d 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(); + float 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) { + float xpos = static_cast(xposIn); + float ypos = static_cast(yposIn); + if (firstMouse) { lastX = xpos; @@ -489,7 +492,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)); } // renders (and builds at first invocation) a sphere @@ -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..bdd36d2 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(); + float 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) { + float xpos = static_cast(xposIn); + float 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)