tags:

views:

61

answers:

2

If i have common style perspective transformation matrix like this

/ focus    0    cx \
|  0     focus  cy |
\  0       0     1 /

how can setup parameters for glFrustum or gluPerspective to get correct transformation

for example:

glFrustum ( -cx, screenWidth - cx, -cy, screenHeight - cy, focus, focus + 1000)
gluLookAt( 0.0, 0.0, -focus,   0.0, 0.0, 0.0,   0.0, 1.0, 0.0);

don't create correct transformation =(

+1  A: 
glMatrixMode(GL_PROJECTION)
glFrustum ( 0, screenWidth ,0, screenHeight, focus, focus + 1000)
glMatrixMode(GL_MODELVIEW)
glLookAt(...)

But the given matrix is not a 4D transformation matrix as expected by openGL; you should check out http://www.opengl.org/sdk/docs/man/xhtml/glFrustum.xml

And you are setting your near clipping plane at "focus", so anything closed will be clipped ! You should choose a more decent value, like 1.0. focus+1000 makes sense, though

Calvin1602
This is exactly equivalent transformation?! i don't see any perspertive distortion... projected lines looks like perallel =(and where should i setup camera principal point (cx,cy)?
Vie
You should use gluPerspective instead of glFrustum, it will be simpler to setup. What do you call "camera principal point" ? in openGL the camera is always at (0,0,0), pointing towards -Z (in world space).
Calvin1602
+1  A: 

I did it!!! =) Maybe someone it will be useful

glFrustum( -znear*cx / fx, znear*(w - cx) / fx,
           -znear*cy / fy, znear*(h - cy) / fy, 
            znear, zfar);
Vie
But it is liner transformation without distortion!
Vie