mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-30 20:13:22 +08:00
fix narrowing conversions (eg double to float, size_t to GLsizei)
This commit is contained in:
@@ -160,7 +160,7 @@ int main()
|
||||
{
|
||||
// per-frame time logic
|
||||
// --------------------
|
||||
float currentFrame = glfwGetTime();
|
||||
auto currentFrame = static_cast<GLfloat>(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<GLfloat>(sin(glfwGetTime() * 2.0));
|
||||
lightColor.y = static_cast<GLfloat>(sin(glfwGetTime() * 0.7));
|
||||
lightColor.z = static_cast<GLfloat>(sin(glfwGetTime() * 1.3));
|
||||
glm::vec3 diffuseColor = lightColor * glm::vec3(0.5f); // decrease the influence
|
||||
glm::vec3 ambientColor = diffuseColor * glm::vec3(0.2f); // low influence
|
||||
lightingShader.setVec3("light.ambient", ambientColor);
|
||||
@@ -270,8 +270,11 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||
|
||||
// glfw: whenever the mouse moves, this callback is called
|
||||
// -------------------------------------------------------
|
||||
void mouse_callback(GLFWwindow* window, double xpos, double ypos)
|
||||
void mouse_callback(GLFWwindow* window, double xposIn, double yposIn)
|
||||
{
|
||||
auto xpos = static_cast<GLfloat>(xposIn);
|
||||
auto ypos = static_cast<GLfloat>(yposIn);
|
||||
|
||||
if (firstMouse)
|
||||
{
|
||||
lastX = xpos;
|
||||
@@ -292,5 +295,5 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos)
|
||||
// ----------------------------------------------------------------------
|
||||
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset)
|
||||
{
|
||||
camera.ProcessMouseScroll(yoffset);
|
||||
camera.ProcessMouseScroll(static_cast<GLfloat>(yoffset));
|
||||
}
|
||||
Reference in New Issue
Block a user