# Unit of length in OpenGL

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) 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.

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.

Thank you.

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

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.

In short : use the units you want, it will not matter.
It can be 1 gl unit = 1 meter, 1 inch, Pi*lightspeed, whatever.

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.