# How does openGL actually use the projection matrix

Hi,

Can someone tell me what maths openGL does internally with the projection matrix when rendering? I’ve tried drawing a wireframe version of the world using my own 2d draws on top the openGL 3d world. They are pretty much the same, expect my own projected 2d lines seem as if there’s a slightly different FOV. This can’t be the case I’ve checked the matrix that I pass to openGL as a GL_PROJECTION_MATRIX, and it’s the same as what I’m using to draw when converting from 3d to 2d. So that must mean I’m not using the projection matrix correctly, or that openGL must be adding an extra step somewhere. My 3d to 2d function looks like this:

void Transform3dto2dScreenCoord( MATRIX *m, VECTOR *v, VECTOR *vout )
{

``````float w;

vout-&gt;x = v-&gt;x*m-&gt;m[MINDEX_00] + v-&gt;y*m-&gt;m[MINDEX_10] + v-&gt;z*m-&gt;m[MINDEX_20] + m-&gt;m[MINDEX_30];
vout-&gt;y = v-&gt;x*m-&gt;m[MINDEX_01] + v-&gt;y*m-&gt;m[MINDEX_11] + v-&gt;z*m-&gt;m[MINDEX_21] + m-&gt;m[MINDEX_31];
vout-&gt;z = v-&gt;x*m-&gt;m[MINDEX_02] + v-&gt;y*m-&gt;m[MINDEX_12] + v-&gt;z*m-&gt;m[MINDEX_22] + m-&gt;m[MINDEX_32];

w = v-&gt;x*m-&gt;m[MINDEX_03] + v-&gt;y*m-&gt;m[MINDEX_13] + v-&gt;z*m-&gt;m[MINDEX_23] + m-&gt;m[MINDEX_33];

vout-&gt;z = vout-&gt;z/w;
vout-&gt;y = vout-&gt;y/w;
vout-&gt;x = vout-&gt;x/w;

vout-&gt;x/=vout-&gt;z;
vout-&gt;y/=vout-&gt;z;

vout-&gt;x *= ScreenWidth;
vout-&gt;y *= ScreenWidth;

vout-&gt;x += ScreenWidth/2;
vout-&gt;y += ScreenHeight/2;
``````

}

Any ideas how this compares to what openGL actually does?