I’m trying to define a perspective matrix when only using viewWidth, viewHeight, nearClip and farClip. I don’t know if it is correct, since I cannot seem to find ANY sources online except for MSDN DirectX, but their method does not work for OpenGL.

```
void Matrix4::setupProjectionMatrixWH(float w, float h, float zNear, float zFar)
{
m[0] = 2*zNear/w;
m[1] = 0;
m[2] = 0;
m[3] = 0;
m[4] = 0;
m[5] = 2*zNear/h;
m[6] = 0;
m[7] = 0;
m[8] = 0;
m[9] = 0;
m[10] = -(zFar + zNear) / (zFar - zNear);
m[11] = -1;
m[12] = 0;
m[13] = 0;
m[14] = -(2.0f * zFar * zNear) / (zFar - zNear);
m[15] = 0;
}
```

I think m[10] and m[14] are calculated correctly, but I’m not sure about m[0] and m[5].