How to decompose projection matrix? I want to decompose projection matrices into near, far, top, bottom, left and right values to create a bounding box for view frustum. I used the formula described in  this site Decompose the OpenGL projection matrix. This formula works for perspective which is created with frustum function (glFrustum). But it does not work for perspective which is created via perspective func (gluPerspective) 

Frustum and perspective may create same perspective effect but generated matrices seems different. So it seems I can't use single formula to extract perspective parameters. 


Is there any proof of that decomposition formula, or does it always work? 
How do I decompose the matrix generated by perspective function into near, far, top, bottom, left and right values? Is there any formula which is already used in industry?


My implementations of ortho, frustum and perspetive is here: https://github.com/recp/cglm/blob/master/include/cglm/cam.h
Do you have any "input data" from which you constructed the matrix (like fov, near plane distance, etc.)? Or is the matrix itself the only data you have?

EDIT:
Ok, so if you want to know the size of the near plane while you have viewProj matrix available do this:

a) compute viewProj^-1

b) vertices of the near plane in clip-space have coordinates (in OpenGL):
(-1, -1, -1, 1)
(-1,  1, -1, 1)
( 1, -1, -1, 1)
( 1,  1, -1, 1)

and on the far plane:
(-1, -1, 1, 1)
(-1,  1, 1, 1)
( 1, -1, 1, 1)
( 1,  1, 1, 1)

It's a unit cube spanning (-1, -1, -1) and (1, 1, 1) coordinates with w=1

c) take each of those vertices, mutiply by viewProj^-1 and finally divide all resulting components by the w-component. That gives you the frustum's vertices in world space. From this you can easily find world space planes constraining the view frustum or the bounding box or whatever you like.

I think it's not possible to extract left/right/bottom/top/near/far from the matrix directly. But since you can compute the world space coordinates of frustum's corners (as shown above) you can easily find left/right/bottom/top/near/far.