I'm trying to create an orthographic projection using GLM for rendering UI elements. I have a window that's 1280x720 and I'm creating the projection like so:
float aspect = (float) height / (float) width;
// args: left, right, bottom, top, ...
glm::mat4 projection = glm::ortho(-1.0, 1.0, -aspect, aspect , near, far); // near: -2.0, far: 2.0
If I create square mesh like this:
auto geometry = Geometry::Primitive::Plane(1.0f, 1.0f * aspect); // (width, height)
Then the square would look too wide, UNLESS I do this:
auto geometry = Geometry::Primitive::Plane(1.0f * aspect, 1.0f * aspect);
What do you all think I'm doing wrong, and what's the best way to construct an orthographic projection for rendering UI elements?
Oh and one last thing: If my height is larger than my width, I'm guessing I would have to switch the division for my aspect ratio?
Thanks all!