I'm trying to change my camera projection from perspective to orthographic. At the moment my code is working fine with the perspective projection
m_prespective = glm::perspective(70.0f, (float)DISPLAY_WIDTH / (float)DISPLAY_HEIGHT, 0.01f, 1000.0f);
m_position = glm::vec3(mesh.centre.x, mesh.centre.y, -mesh.radius);
m_forward = centre;
m_up = glm::vec3(0.0f, 1.0f, 0.0f);
return m_prespective * glm::lookAt(m_position, m_forward, m_up);
But as soon as i change it to orthographic projection I can't see my mesh anymore.
m_ortho = glm::ortho(0.0f, (float)DISPLAY_WIDTH, (float)DISPLAY_HEIGHT,5.0f, 0.01f, 1000.0f);
m_position = glm::vec3(mesh.centre.x, mesh.centre.y, -mesh.radius);
m_forward = centre;
m_up = glm::vec3(0.0f, 1.0f, 0.0f);
return m_ortho * glm::lookAt(m_position, m_forward, m_up);
I don't understand what I'm doing wrong.
ortho
? The signature should beortho(left, right, bottom, top, near, far)
. What's that 5.0? – peppem_ortho = glm::ortho(0.0f, 800.0f, 600.0f ,5.0f, 0.01f, 1000.0f);
tom_ortho = glm::ortho(8.0f, 0.0f,0.0f,6.0f, 0.1f, 100.0f);
makes the size go back to normal (more or less). But I don't understand if there's a rule or a specific relation for changing the size values from perspective projection to orthographic projection. (Just to avoid changing them manually every time) – Izzy88