mpen
mpen

Reputation: 282875

GLSL coordinate space?

Do I have to map gl_Position to be within (-1,-1),(1,1) for it to appear on screen, or what? i.e., is (-1,-1) the top left, and (1,1) the bottom right?

Before I was just using my library's CreatePerspectiveFieldOfView and it took care of all the conversions for me, but I'm writing my own now and I'm not quite sure what I need to map the coords to...

Upvotes: 1

Views: 329

Answers (1)

Matti Virkkunen
Matti Virkkunen

Reputation: 65126

gl_Position is a 4-vector, so it has more than just those two elements, usually named x, y, z and w. When clipping, the coordinates are clipped to [-w, w], or in other words, after normalization (dividing each coordinate by w), to [-1, 1]. So normalized coordinates are clipped by the cube (-1, -1, -1) - (1, 1, 1) (unless you have defined more clip planes).

For more information on clipping, read

http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node28.html

Upvotes: 1

Related Questions