I am a little confused by how the matrix generated by gluPerspective accounts for the ‘w’ component of a given vertex.

Looking up the matrix generated by gluPerspective online, gives me that the matrix has the general form:

| A 0 0 0 |

| 0 B 0 0 |

| 0 0 C D |

| 0 0 -1 0|

Call this matrix M.

The specific values of A,B,C and D are not important for this discussion (I think). Right multiplying this matrix by a 4x1 vector (x,y,z,w) we obtain:

x’ = Ax,

y’ = Bx,

z’ = Cz+Dw

w’ = -z

This relationship puzzles me becuse x’ and y’ do not in any way depend on w.

My understanding was that if w=1/2 for instance, the resulting x’,y’, z’ should be scaled by a factor of 2 after dividing by the w’ component. But this projection transformation seems to have removed the affect of w on x’ and y’, and so they would NOT be multiplied by 2.

Can someone clear this up for me?