title: Using OpenGL in Matlab to get depth buffer
body: <p>Ive asked a similar question before and didnt manage to find a direct <a href="https://stackoverflow.com/questions/5963193/matlab-z-buffer-for-simulating-kinect">answer</a>.</p>
  
  <p>Could someone provide sample code for extracting the depth buffer of the rendering of an object into a figure in Matlab?</p>
  
  <p>So lets say I load an obj file or even just a simple surf call, render it and now want to get to its depth buffer then what code will do that for me using both Matlab and OpenGL. I.e. how do I set this up and then access the actual data? </p>
  
  <p>I essentially want to be able to use Matlabs powerful plotting functions and then be able to access the underlying graphics context for getting the depth buffer out.</p>
  
  <p>NOTE: The bounty specifies JOGL but that is not a must. Any code which acts as above and can provide me with the depth buffer after running it in Matlab is sufficient)</p>