From 6d2363d10adf7034619fa314a5f408d10740fec4 Mon Sep 17 00:00:00 2001 From: ponchio Date: Fri, 21 Nov 2008 17:22:58 +0000 Subject: [PATCH] There was a bug in TransformGL for perspective matrix. The function worked as intended only if near == focal. --- wrap/gl/camera.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/wrap/gl/camera.h b/wrap/gl/camera.h index 4fa8c719..0317c76b 100644 --- a/wrap/gl/camera.h +++ b/wrap/gl/camera.h @@ -147,8 +147,16 @@ static void GetFrustum(vcg::Camera & intrinsics, S & sx,S & dx,S & bt,S & tp, /// set the OpenGL PROJECTION matrix to match the camera (intrinsics). requires near and far plane static void TransformGL(vcg::Camera & camera, S nearDist, S farDist ) { - S sx,dx,bt,tp,nr,fr; - camera.GetFrustum(sx,dx,bt,tp,nr); + S sx,dx,bt,tp,nr; + camera.GetFrustum(sx,dx,bt,tp,nr); + + if(camera.cameraType == vcg::PERSPECTIVE) { + S ratio = nearDist/nr; + sx *= ratio; + dx *= ratio; + bt *= ratio; + tp *= ratio; + } assert(glGetError()==0);