PDA

View Full Version : Squished Y Co-ordinates



larryl
01-15-2017, 03:00 PM
Hi Again Folks:

What a great forum, thanks for your help.

And what a great tutorial.

However, I have noticed something that seems odd.

This (https://learnopengl.com/#!Getting-started/Textures) lesson, on drawing textures, and the one after it on transformations seem to draw square 2D objects as rectangles that are definitely wider than they are high.

I've solved my problem.

The examples specify the window dimensions passed into glfwCreateWindow() as 800 x 600.

This sets a ratio of width to height to anything drawn.

Simply make the last operation performed on any object drawn a scale with a Y of that width divided by the height.

Larry

GClements
01-15-2017, 08:39 PM
This (https://learnopengl.com/#!Getting-started/Textures) lesson, on drawing textures, and the one after it on transformations seem to draw square 2D objects as rectangles that are definitely wider than they are high.

I've solved my problem.

The examples specify the window dimensions passed into glfwCreateWindow() as 800 x 600.

This sets a ratio of width to height to anything drawn.

This is normally dealt with by the projection transformation. Typically, you either pass the viewport's aspect ratio as a parameter (e.g. gluPerspective), or take it into account when specifying the horizontal and vertical bounds. Either way, the result is that one unit in eye coordinates corresponds to the same size on screen regardless of whether the direction is horizontal or vertical.

Ideally, you'd calculate the aspect ratio using the physical dimensions in mm, rather than the number of pixels, so as to get correct results on monitors with non-square pixels.