# OpenGL OpenGL FOV & Units

This topic is 3428 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Aloha! I've always dealt with openGL in a way that just seemed to look right. Every object seemed realistically proportional with a 60 to 90 degree Field of View. All was great until recently... I'm currently working on something that requires everything to look as realistic as possible (size-wise). That being said, I wish to make OpenGL units in centimeters so that if I specify a line to be 1.0 openGL unit, then it will actually be 1 cm on screen(and will be able to be verified with an actual ruler). Let's initially assume I'm using orthographic projection. That being said, 1.0 ogl unit would correspond to 1 pixel. For me to get 1 cm, would I be required to do a "glScale3f" before rendering that would make the 1.0 ogl unit into 1 cm? I calculated that there are approximately 34 pixels in 1 cm on my screen (1280x1024). Now let's assume perspective projection. This is where I find things most confusing. How would I set up the same type of situation? Let's say I sit 60 centimeters away from my screen. For me to see a centimeter on screen as I would in real life, would I have to position the openGL camera 60 units away? For Field of View calculation, would I just use the angle from the center of my eyes to the sides of my screen? Hopefully someone can shed some light on this. I tried looking in books and on the internet, but to no avail. Perspective projection really gets my mind in knots. db

##### Share on other sites
For an orthographic projection, just set the values to whatever dimension you want. If you want 1 unit to be 1 cm, and your window is 34 cm wide, then the view volume must be 34 units wide.

For perspective, you need to calculate a proper field of view. If you consider your world around you as the scene, and your monitor as a viewport into the scene, you can figure out the FOV as the angle between your eyes and the borders of the window. So, the horizontal FOV shall match the angle between the left edge, your face, and the right edge of the window. Typically, this is around 40 degrees. You can calculate the FOV as atan(w*d/2)*2, where w is the width of the window and d is the distance from the monitor to your face.

##### Share on other sites
Quote:
 Original post by Brother BobYou can calculate the FOV as atan(w*d/2)*2, where w is the width of the window and d is the distance from the monitor to your face.

Shouldn't that be atan((w/2)/d)*2?

##### Share on other sites
Quote:
 Original post by SneftelShouldn't that be atan((w/2)/d)*2?

Yes, that's correct.

Quote:
 Original post by Brother BobIf you want 1 unit to be 1 cm, and your window is 34 cm wide, then the view volume must be 34 units wide.

When you say "make the viewing volume 34 units", how do you propose doing this?

##### Share on other sites
Quote:
Original post by Beatcow
Quote:
 Original post by SneftelShouldn't that be atan((w/2)/d)*2?

Yes, that's correct.

Indeed it should. Typo on my part.
Quote:
Original post by Beatcow
Quote:
 Original post by Brother BobIf you want 1 unit to be 1 cm, and your window is 34 cm wide, then the view volume must be 34 units wide.

When you say "make the viewing volume 34 units", how do you propose doing this?

For example, if the screen is 34x20 cm (a 16:9 monitor), glOrtho(0, 34, 0, 20, -1, 1) will give you cm-based units.

##### Share on other sites
Thanks Brother Bob! I'll give it a shot.

1. 1
Rutin
28
2. 2
3. 3
4. 4
5. 5

• 11
• 13
• 11
• 10
• 13
• ### Forum Statistics

• Total Topics
632952
• Total Posts
3009438
• ### Who's Online (See full list)

There are no registered users currently online

×