Cube shape appears distorted at edge of viewport

I am not sure whether this is standard perspective behaviour. See the png image here and also attached:

http://www.mediafire.com/?7sofo9qq763wfh5

I have a fairly short and wide viewport area. I am using:

GLU.gluPerspective(gl,25, (float) width / (float) height, 0.1f,100.0f);

to set up my perspective.

I am then drawing three cubes, one far left, one in the centre and one far right, their placement controlled by gl.glTranslatef. The one in the centre appears correct, but those on the left and right dont look correct at all, the perspective seems very wrong, like a fisheye lens or a very widescreen camera shot.

On the left cube, why is the edge on the left longer than the edge on the right? And vice versa on the cube on the right?

I note that the distortion is proportional to the horizontal distance from the centre of the viewport, as I move the cubes nearer the centre, they look much more natural.

Is this normal behaviour on such a perspective projection, or have I done something wrong? Is there any way round it?

Unfortunately I cannot have 3 seperate viewports in my app, I must display all three cubes on a single window.

Thanks for any advice…

what is value of the ratio width/height?

25 degrees can be pretty high.

Imaging you are taking a picture of somebody very close to the camera with extreme zoom out (fovy is big), you have a very distorted face. If you want less distortion on the face, you make sure the subject is far enough from the camera and you zoom in at the same time (fovy is smaller).

Here is a real-life example:
http://neilvn.com/tangents/2012/02/06/composition-for-full-length-portraits/

So try to move your cubes away from the camera and use a smaller value for fovy. (At the limit, when fovy is very close to zero the frustum planes are almost parallel and it is much like a parallel projection)

Look also at the 2 animations on the right side of the “Dolly zoom” wikipedia page:

http://en.wikipedia.org/wiki/Vertigo_effect

Indeed this is completely expected.
With gluPerspective the fov is the vertical fov. With such an extremely wide viewport, it means the horizontal fov is extreme too.

Unfortunately I cannot have 3 seperate viewports in my app, I must display all three cubes on a single window.

A GL viewport is not a window. You can have several viewports on a single window, and that would be the ideal solution I would implement if I were in your shoes.

Wonderful, thanks for the answers and the clarification. Thought it had to be something simple.

The aspect ratio for the window showing the cubes is the same size as the screenshot, 800/180, 4.4444.

I will play with the cube distance and fov angle first.

I did 3 things to solve this.

Firstly as the problem was more noticeable in Landscape mode, where the viewport was a lot wider, I centered the 3 cubes rather than have them fill the entire width of the screen. That reduced the distortion but not by much.

Secondly as suggested I reduced the fov from 25 degrees to 12 degrees, and thirdly moved the cubes further away.

A bit of tweaking of the size and horizontal displacement, and it looks much better, as attached.

I also had a play around with my wide angle camera also, with helped me understand more what is going on in terms of zooming, fov etc.

Thanks again for the help, it is much appreciated.

James