mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-03 23:33:23 +08:00
Spheres model matrix generation fix
Fix of integer division resulting in some spheres being rendered at same position. Removed redundant float cast as all operands are being promoted to double anyways.
This commit is contained in:
@@ -43,7 +43,10 @@ int main()
|
|||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||||
glfwWindowHint(GLFW_SAMPLES, 4);
|
glfwWindowHint(GLFW_SAMPLES, 4);
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
//glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // uncomment this statement to fix compilation on OS X
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // uncomment this statement to fix compilation on OS X
|
||||||
|
#endif
|
||||||
|
|
||||||
// glfw window creation
|
// glfw window creation
|
||||||
// --------------------
|
// --------------------
|
||||||
@@ -102,7 +105,7 @@ int main()
|
|||||||
|
|
||||||
// initialize static shader uniforms before rendering
|
// 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.use();
|
||||||
shader.setMat4("projection", projection);
|
shader.setMat4("projection", projection);
|
||||||
|
|
||||||
@@ -143,8 +146,8 @@ int main()
|
|||||||
|
|
||||||
model = glm::mat4();
|
model = glm::mat4();
|
||||||
model = glm::translate(model, glm::vec3(
|
model = glm::translate(model, glm::vec3(
|
||||||
(float)(col - (nrColumns / 2)) * spacing,
|
(col - (nrColumns / 2.)) * spacing,
|
||||||
(float)(row - (nrRows / 2)) * spacing,
|
(row - (nrRows / 2.)) * spacing,
|
||||||
0.0f
|
0.0f
|
||||||
));
|
));
|
||||||
shader.setMat4("model", model);
|
shader.setMat4("model", model);
|
||||||
|
|||||||
Reference in New Issue
Block a user