0
\$\begingroup\$

I am learning OpenGL. Clip space, normalized device coordinate space and window space are confusing. I searched but still don't understand them clearly. So, the question is- what are differences between them and how are they converted from one to another? And what coordinate do the built-in OpenGL functions (e.g.: glBufferData) take as input?

\$\endgroup\$
2
\$\begingroup\$

Clip space is the objects' position in a coordinate system relative to the camera. -Z is always in the same direction the camera is pointing. You get it by doing the necessary transformations on the world space positions.

Normalized device cooridnate (or NDC for short) is the same coordinate system, but the Z values are in the 0->1 range. This can be achieved by dividing the x and y with z.

Window space is the NDC converted to device coordinates. OpenGL multiplies x with the width of the screen, and y with the height.

Your last question makes no sense in it's current state. Buffers can store everything, and they could store the same data in multiple different formats.

\$\endgroup\$
  • \$\begingroup\$ About my last question- suppose I have 3 vertices: (x1, y1, z1, w1), (x2, y2, z2, w2) and (x3, y3, z3, w3). Now If I use glDrawArrays to draw a triangle with those vertices, will those coordinate of vertices work as clip-space coordinate or NDC coordinate (or something else). \$\endgroup\$ – Shuvo Sarker Apr 20 '17 at 8:07
  • \$\begingroup\$ @Shuvo They'll work as world space coordinates, but because you don't do anything with them in the shader, the world space coordinates will be the same in clip space and normalized device coordinates space. \$\endgroup\$ – Bálint Apr 20 '17 at 9:54
  • \$\begingroup\$ So, you mean glDrawArrays treats the coordinates, it works with, as NDC? If yes, then is it true for every OpenGL drawing call? Thanks... \$\endgroup\$ – Shuvo Sarker Apr 20 '17 at 11:42
  • \$\begingroup\$ @Shuvo If you don't do anything with them in your shader. \$\endgroup\$ – Bálint Apr 21 '17 at 5:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.