Search code examples
c++openglscalingcoordinate-systemsunits-of-measurement

OpenGl changing the unit of measure for coordinate system


I'm learning OpenGL using the newest blue book, and I was hoping to get a point of clarification. The book says you can use any system of measurement for the coordinate system, however when doing 3d perspective programming, the world coordinates are +1/-1.

I guess where I am a little confused is lets say I want to use feet and inches for my world, and I want to build the interior of my house. Would I just use translates (x(feet), y(feet), z(feet)), extra, or is there some function to change you x,y world coordinates (i.e change the default from -1/+1 to lets say (-20/20). I know openGl converts everything unit left.

So i guess My biggest gap of knowledge is how to I model real world objects (lengths) to make sense in OPenGL?


Solution

  • I think the author is referring to normalized coordinates (device coordinates) that appear after the perspective divide.

    Typically when you actually manipulate objects in OpenGL you use standard world coordinates which are not limited to -1/+1. These world coordinates can be anything you like and are translated into normalized coordinates by multiplying by the modelview and projection matrices then dividing by the homogeneous coordinate 'w'.

    OpenGL will do all this for you (until you get into shaders) so don't really worry about normalized coordinates.