View Full Version : Unit of length in OpenGL

HaVyThoai

11-15-2007, 11:23 PM

Dear everybody,

I got a question about unit of length in OpenGL. Assuming that I want to render a cube with the length of the sides of the cube is 20 millimetre, then what number I have to put in command glutWireCube( ???? f)

:(

Korval

11-15-2007, 11:29 PM

I got a question about unit of length in OpenGL.

There is no unit of length in OpenGL. It is whatever you want it to be, based on your projection matrices and camera location.

k_szczech

11-16-2007, 03:31 AM

You simply assume any unit you want.

For example - you may assume unit is 1m and draw cube that has size of 0.02 or you can assume it's 1mm and draw a cube of size 20.

You just need to use the same units when defining your view

frustum (projection matrix).

I always use 1m since it's the basic unit used in many physics related formulas.

HaVyThoai

11-16-2007, 05:06 AM

Thank you.

but It's hard to understand, an example woulb be helpful for me

Cgor_Cyrosly

11-16-2007, 08:36 AM

That means is the size of cube you look at the screen can be looked has the different size through the projection matrix with different parameters although you set the same size for the cube.

Note,you are draw in the space of virtual world,not the real world.

ZbuffeR

11-16-2007, 10:27 AM

In short : use the units you want, it will not matter.

It can be 1 gl unit = 1 meter, 1 inch, Pi*lightspeed, whatever.

zeoverlord

11-16-2007, 01:51 PM

I usually use 1 unit = 1 meter, it makes everything easy when adding motion, physics and stuff like that, as you can just copy the values and formulas directly from an SI based physics book.

Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.