mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-02 04:37:54 +08:00
fix: use radians instead of degrees for camera zoom.
This commit is contained in:
@@ -193,7 +193,7 @@ int main()
|
||||
shader.use();
|
||||
glm::mat4 model;
|
||||
glm::mat4 view = camera.GetViewMatrix();
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
shader.setMat4("view", view);
|
||||
shader.setMat4("projection", projection);
|
||||
// cubes
|
||||
|
||||
@@ -193,7 +193,7 @@ int main()
|
||||
shader.use();
|
||||
glm::mat4 model;
|
||||
glm::mat4 view = camera.GetViewMatrix();
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
shader.setMat4("view", view);
|
||||
shader.setMat4("projection", projection);
|
||||
// cubes
|
||||
|
||||
@@ -230,7 +230,7 @@ int main()
|
||||
|
||||
// set transformation matrices
|
||||
shader.use();
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 1000.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 1000.0f);
|
||||
shader.setMat4("projection", projection);
|
||||
shader.setMat4("view", camera.GetViewMatrix());
|
||||
shader.setMat4("model", glm::mat4());
|
||||
|
||||
@@ -198,7 +198,7 @@ int main()
|
||||
shaderSingleColor.use();
|
||||
glm::mat4 model;
|
||||
glm::mat4 view = camera.GetViewMatrix();
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
shaderSingleColor.setMat4("view", view);
|
||||
shaderSingleColor.setMat4("projection", projection);
|
||||
|
||||
|
||||
@@ -223,7 +223,7 @@ int main()
|
||||
|
||||
// draw objects
|
||||
shader.use();
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 view = camera.GetViewMatrix();
|
||||
glm::mat4 model;
|
||||
shader.setMat4("projection", projection);
|
||||
|
||||
@@ -234,7 +234,7 @@ int main()
|
||||
|
||||
// draw objects
|
||||
shader.use();
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 view = camera.GetViewMatrix();
|
||||
glm::mat4 model;
|
||||
shader.setMat4("projection", projection);
|
||||
|
||||
@@ -248,7 +248,7 @@ int main()
|
||||
shader.use();
|
||||
glm::mat4 model;
|
||||
glm::mat4 view = camera.GetViewMatrix();
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
shader.setMat4("view", view);
|
||||
shader.setMat4("projection", projection);
|
||||
// cubes
|
||||
|
||||
@@ -256,7 +256,7 @@ int main()
|
||||
camera.Yaw -= 180.0f; // reset it back to its original orientation
|
||||
camera.Pitch -= 180.0f;
|
||||
camera.ProcessMouseMovement(0, 0, true);
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
shader.setMat4("view", view);
|
||||
shader.setMat4("projection", projection);
|
||||
// cubes
|
||||
|
||||
@@ -239,7 +239,7 @@ int main()
|
||||
shader.use();
|
||||
glm::mat4 model;
|
||||
glm::mat4 view = camera.GetViewMatrix();
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
shader.setMat4("model", model);
|
||||
shader.setMat4("view", view);
|
||||
shader.setMat4("projection", projection);
|
||||
|
||||
@@ -237,7 +237,7 @@ int main()
|
||||
shader.use();
|
||||
glm::mat4 model;
|
||||
glm::mat4 view = camera.GetViewMatrix();
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
shader.setMat4("model", model);
|
||||
shader.setMat4("view", view);
|
||||
shader.setMat4("projection", projection);
|
||||
|
||||
@@ -144,7 +144,7 @@ int main()
|
||||
|
||||
// draw objects
|
||||
shader.use();
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 view = camera.GetViewMatrix();
|
||||
shader.setMat4("projection", projection);
|
||||
shader.setMat4("view", view);
|
||||
|
||||
@@ -156,7 +156,7 @@ int main()
|
||||
|
||||
// draw objects
|
||||
shader.use();
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 view = camera.GetViewMatrix();
|
||||
shader.setMat4("projection", projection);
|
||||
shader.setMat4("view", view);
|
||||
|
||||
@@ -200,7 +200,7 @@ int main()
|
||||
glViewport(0, 0, SCR_WIDTH, SCR_HEIGHT);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
shader.use();
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 view = camera.GetViewMatrix();
|
||||
shader.setMat4("projection", projection);
|
||||
shader.setMat4("view", view);
|
||||
|
||||
@@ -208,7 +208,7 @@ int main()
|
||||
glViewport(0, 0, SCR_WIDTH, SCR_HEIGHT);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
shader.use();
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 view = camera.GetViewMatrix();
|
||||
shader.setMat4("projection", projection);
|
||||
shader.setMat4("view", view);
|
||||
|
||||
@@ -176,7 +176,7 @@ int main()
|
||||
glViewport(0, 0, SCR_WIDTH, SCR_HEIGHT);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
shader.use();
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 view = camera.GetViewMatrix();
|
||||
shader.setMat4("projection", projection);
|
||||
shader.setMat4("view", view);
|
||||
|
||||
@@ -176,7 +176,7 @@ int main()
|
||||
glViewport(0, 0, SCR_WIDTH, SCR_HEIGHT);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
shader.use();
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 view = camera.GetViewMatrix();
|
||||
shader.setMat4("projection", projection);
|
||||
shader.setMat4("view", view);
|
||||
|
||||
@@ -115,7 +115,7 @@ int main()
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// configure view/projection matrices
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 view = camera.GetViewMatrix();
|
||||
shader.use();
|
||||
shader.setMat4("projection", projection);
|
||||
|
||||
@@ -121,7 +121,7 @@ int main()
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// configure view/projection matrices
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 view = camera.GetViewMatrix();
|
||||
shader.use();
|
||||
shader.setMat4("projection", projection);
|
||||
|
||||
@@ -121,7 +121,7 @@ int main()
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// configure view/projection matrices
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 view = camera.GetViewMatrix();
|
||||
shader.use();
|
||||
shader.setMat4("projection", projection);
|
||||
|
||||
@@ -121,7 +121,7 @@ int main()
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// configure view/projection matrices
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 view = camera.GetViewMatrix();
|
||||
shader.use();
|
||||
shader.setMat4("projection", projection);
|
||||
|
||||
@@ -158,7 +158,7 @@ int main()
|
||||
// -----------------------------------------------
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, hdrFBO);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (GLfloat)SCR_WIDTH / (GLfloat)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (GLfloat)SCR_WIDTH / (GLfloat)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 view = camera.GetViewMatrix();
|
||||
shader.use();
|
||||
shader.setMat4("projection", projection);
|
||||
|
||||
@@ -194,7 +194,7 @@ int main()
|
||||
// -----------------------------------------------
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, hdrFBO);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 view = camera.GetViewMatrix();
|
||||
glm::mat4 model;
|
||||
shader.use();
|
||||
|
||||
@@ -105,7 +105,7 @@ int main()
|
||||
|
||||
// initialize static shader uniforms before rendering
|
||||
// --------------------------------------------------
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
shader.use();
|
||||
shader.setMat4("projection", projection);
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ int main()
|
||||
|
||||
// initialize static shader uniforms before rendering
|
||||
// --------------------------------------------------
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
shader.use();
|
||||
shader.setMat4("projection", projection);
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ int main()
|
||||
|
||||
// initialize static shader uniforms before rendering
|
||||
// --------------------------------------------------
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
pbrShader.use();
|
||||
pbrShader.setMat4("projection", projection);
|
||||
backgroundShader.use();
|
||||
|
||||
@@ -238,7 +238,7 @@ int main()
|
||||
|
||||
// initialize static shader uniforms before rendering
|
||||
// --------------------------------------------------
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
pbrShader.use();
|
||||
pbrShader.setMat4("projection", projection);
|
||||
backgroundShader.use();
|
||||
|
||||
@@ -326,7 +326,7 @@ int main()
|
||||
|
||||
// initialize static shader uniforms before rendering
|
||||
// --------------------------------------------------
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
pbrShader.use();
|
||||
pbrShader.setMat4("projection", projection);
|
||||
backgroundShader.use();
|
||||
|
||||
@@ -366,7 +366,7 @@ int main()
|
||||
|
||||
// initialize static shader uniforms before rendering
|
||||
// --------------------------------------------------
|
||||
glm::mat4 projection = glm::perspective(camera.Zoom, (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
pbrShader.use();
|
||||
pbrShader.setMat4("projection", projection);
|
||||
backgroundShader.use();
|
||||
|
||||
Reference in New Issue
Block a user