# Finding out the near clipping plane

So assuming I don’t have access to the code that sets the near clipping plane is there a way of getting this value out of the GL?

For standard projection matrix you have something like that
http://www.opengl.org/sdk/docs/man/xhtml/gluPerspective.xml

a = projectionM[10]
b = projectionM[14]

With some simple math…
<div class=“ubbcode-block”><div class=“ubbcode-header”>Click to reveal… <input type=“button” class=“form-button” value=“Show me!” onclick=“toggle_spoiler(this, ‘Yikes, my eyes!’, ‘Show me!’)” />]<div style=“display: none;”>[1] a = (n+f)/(n-f)
[2] b = 2nf/(n-f)

[1] became (if n != f)
(n-f)a = n+f => an-af = n+f => an-n = af+f => n = f(a+1)/(a-1) (if a != 1)
now you can isolate n in [2]
b(n-f) = 2nf
bn-2nf = bf
n = bf/(b-2f)

so
bf/(b-2f) = f(a+1)/(a-1)
if(f != 0)
b/(b-2f) = (a+1)/(a-1)
and here is simple, with a little of patience you get
f=b/(a+1)

n = f(a+1)/(a-1)
so
n = b/(a-1)

So, at the end you get[/QUOTE]</div>
f = b/(a+1)
n = b/(a-1)
if(a!=1, a!=-1, f!=n, b!=2f)
far plane = f
near plane = n

Many thanks, that is a fantastic reply