I'm trying to render some objects but apparently X and Y coordinates need to be really small in-order to get something on screen. See this example of 2 lines

enter image description here

The world space coordinates for these lines are

vertices.push_back(glm::vec3(-1.0, 1.0, -2.0)); //line 1 
vertices.push_back(glm::vec3(1.0, 1.0, -2.0));
vertices.push_back(glm::vec3(1.0, -1.0, -2.0)); // line 2
vertices.push_back(glm::vec3(-1.0, -1.0, -2.0));

My view and projection matrices are being set as

proj = glm::perspectiveFov(glm::radians(60), 1280, 720, 0.1, 1000);
view = glm::lookAt(glm::vec3(0,0,300), glm::vec3(0,0,-1), glm::vec3(0,1,0));

As you can see, the lines are actually showing up when I place the camera 300 units back and that's a lot to see lines that have X and Y coordinates in range -1 to +1, atleast that's what I think or perhaps I'm wrong and it's fine?

I remember scaling the range of X and Y in legacy opengl using glOrtho etc. Don't quite get what's the problem here since the matrices seem pretty normal to me. I've also checked the values of the matrices and they are coming up fine using the original math so the glm function is working as intended. Anything I'm forgetting here? Would appreciate some ideas.

EDIT:- I'm an effin idiot, was using glm::radians twice, once when passing it to my class then once inside.


1 Answer 1


I was converting the angle to radians twice guys. Moral of the story is to take breaks when coding.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.