I'm working on an OpenGL 1.x implementation for the Sega Dreamcast. Because the Dreamcast didn't have any hardware T&L the entire vertex transformation pipeline has to be done in software.
What also has to be done in software is clipping to the near-Z plane as failure to clip results in the polygon being dropped entirely from rendering by the hardware.
I'm having some trouble getting the transform -> clip -> perspective divide process working correctly and basically I can sum up the problem as follows:
Something seems very wrong here. The projection matrix is being generated in the same way as described in the glFrustum docs.
So my question is, if I have a coordinate on the near plane, should its Z value be zero after transform by the projection matrix or should it be the near-z distance, or something else?
After clipping polygons to the W = 0.000001 plane, should the generated Z coordinates be -0.000001?
Well that looks right to me. your projection matrix should be bringing you into normalized device coordinates which range from [-1,1], correct? The Z value should represent your depth and is used by the depth buffer, if I'm not mistaken. If you're in 2D using 4x4 matrices, I would imagine you should expect to see 0 in every Z output, as that zero should cancel out any final results, and if you aren't then I would certainly track down where that Z value is creeping from.