Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17625

Need help understanding orthographic projection for UI rendering

$
0
0

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 …

Viewing all articles
Browse latest Browse all 17625

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>