EgtGraphics :

- migliorato calcolo centro di vista in Zwin utilizzando GetPixelZ.
This commit is contained in:
Dario Sassi
2026-01-22 11:00:44 +01:00
parent bbe4e99fe8
commit bcb3c189a1
3 changed files with 24 additions and 1 deletions
+18
View File
@@ -941,6 +941,24 @@ Scene::UnProject( const Point3d& ptView, Point3d& ptWorld) const
return ( nRes == GL_TRUE) ;
}
//----------------------------------------------------------------------------
bool
Scene::GetPixelZ( const Point3d& ptWin, double& dWinZ)
{
glGetError() ;
GLint Viewport[ 4] ;
glGetIntegerv( GL_VIEWPORT, Viewport) ;
float dZ ;
glReadBuffer( GL_FRONT) ;
glReadPixels( int( ptWin.x), Viewport[3] - int( ptWin.y), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &dZ) ;
if ( glGetError() == GL_NO_ERROR && dZ > 0.001 && dZ < 0.999) {
dWinZ = dZ ;
return true ;
}
dWinZ = GetProjectedCenter().z ;
return false ;
}
//----------------------------------------------------------------------------
void
Scene::Destroy( void)