OpenGL expects all the vertices, that we want to become visible, to be in normalized device coordinates after each vertex shader run. That is, the x, y and z coordinates of each vertex should be between -1.0 and 1.0; coordinates outside this range will not be visible.

將坐標(biāo)變換為標(biāo)準(zhǔn)化設(shè)備坐標(biāo),接著再轉(zhuǎn)化為屏幕坐標(biāo)的過(guò)程通常是分步進(jìn)行的,也就是類似于流水線那樣子。在流水線中,物體的頂點(diǎn)在最終轉(zhuǎn)化為屏幕坐標(biāo)之前還會(huì)被變換到多個(gè)坐標(biāo)系統(tǒng)(Coordinate System)。將物體的坐標(biāo)變換到幾個(gè)過(guò)渡坐標(biāo)系(Intermediate Coordinate System)的優(yōu)點(diǎn)在于,在這些特定的坐標(biāo)系統(tǒng)中,一些操作或運(yùn)算更加方便和容易,這一點(diǎn)很快就會(huì)變得很明顯。對(duì)我們來(lái)說(shuō)比較重要的總共有5個(gè)不同的坐標(biāo)系統(tǒng):
- 局部空間(Local Space,或者稱為物體空間(Object Space))
- 世界空間(World Space)
- 觀察空間(View Space,或者稱為視覺(jué)空間(Eye Space))
- 裁剪空間(Clip Space)
- 屏幕空間(Screen Space)
- Local coordinates are the coordinates of your object relative to its local origin; they're the coordinates your object begins in.
- The next step is to transform the local coordinates to world-space coordinates which are coordinates in respect of a larger world. These coordinates are relative to a global origin of the world, together with many other objects also placed relative to the world's origin.
- Next we transform the world coordinates to view-space coordinates in such a way that each coordinate is as seen from the camera or viewer's point of view.
- After the coordinates are in view space we want to project them to clip coordinates. Clip coordinates are processed to the -1.0 and 1.0 range and determine which vertices will end up on the screen.
- And lastly we transform the clip coordinates to screen coordinates in a process we call viewport transform that transforms the coordinates from -1.0 and 1.0 to the coordinate range defined by glViewport. The resulting coordinates are then sent to the rasterizer to turn them into fragments.
You probably got a slight idea what each individual space is used for. The reason we're transforming our vertices into all these different spaces is that some operations make more sense or are easier to use in certain coordinate systems. For example, when modifying your object it makes most sense to do this in local space, while calculating certain operations on the object with respect to the position of other objects makes most sense in world coordinates and so on. If we want, we could define one transformation matrix that goes from local space to clip space all in one go, but that leaves us with less flexibility.