The OpenGL coordinate system is a right-handed Cartesian coordinate system suitable for 3D rendering. Here are the basics:
1. The 3D coordinate system in OpenGL
2. Right-handed coordinate system
3. View coordinates and normalization
4. Camera and transformations
5. Perspective and projections
1.) The 3D coordinate system in OpenGL
- X-axis : Runs from left to right (negative to positive).
- Y-axis : Runs from bottom to top (negative to positive).
- Z-axis : Runs from front to back (negative to positive).
2.) Right-handed coordinate system
OpenGL uses a right-handed coordinate system by default :
- If you are using the right hand and hold the thumb along the X axis , the index finger along the Y axis , then your middle finger points forward (off the screen) along the Z axis .
3.) View coordinates and normalization
- The standard OpenGL coordinate system normally has the origin (0,0,0) in the center of the window.
- Positive Z values point into the depth of the screen .
- Negative Z values point out of the screen .
- Objects with a Z value outside the viewable range (e.g., smaller than the near-clipping plane) are not rendered.
4.) Camera and transformations
OpenGL does not render objects in their original model coordinate system, but transforms them into different coordinate systems:
1. Model coordinates : Local coordinates of an object.
2. World coordinates : Transformed positions relative to the scene.
3. View coordinates (camera coordinates) : Converted to the camera's field of view.
4. Clip coordinates : After projection transformation (e.g., perspective or orthographic projection).
5. Normalized device coordinates (NDC) : Scaled values in the range -1 to 1 for X, Y, and Z.
6. Viewport coordinates : Converted to screen coordinates.
5.) Perspective and projections
- Orthogonal projection : No perspective distortion, all lines remain parallel.
- Perspective projection : Distant objects appear smaller, creating a more realistic sense of depth.
(Image-1) Understanding the OpenGL xyz coordinate system! |
![]() |
