Split Screen and Perspective Problem

I am trying to build an app with a split screen, where both the top and bottom halves of the window show the same scene. The problem is that if I set the projection matrix w/ an aspect ratio of winX/(winY/2) (which I expect to be correct), the perspective in the top rendering (which is drawn first) is stretched vertically and the bottom rendering looks good.

If I change the aspect ratio to winX/winY, the top looks good and the bottom is stretched horizontally. I’m not sure why this is. Any help would be greatly appreciated.

My code is:

glViewport(0, winSizeY/2, winSizeX, winSizeY);

glMatrixMode (GL_PROJECTION); glLoadIdentity();

gluPerspective(45.0f, (GLfloat)winSizeX/(GLfloat)(winSizeY/2), 1.0f, 50.0f);

glMatrixMode( GL_MODELVIEW );



glViewport(0, 0, winSizeX, winSizeY/2);


glViewport(0, winSizeY/2, winSizeX, winSizeY);

There’s yer problem. The two first parameters tells OpenGL where you want the viewport to start, and that’s OK. But the two last does not tell OpenGL where the viewport ends, it tells OpenGL how large the viewport is.

Your viewport is extending from (0, winSizeY/2) to (0 + winSizeY, winSizeY/2 + winSizeY); The viewport ends outside the window in the Y-direction.

If you want split screen where both parts are of equal size, the two last parameters in the two calls to glViewport must be equal. Add an extra “/2” after the last parameter in the first call to glViewport.

Oh, you mean I should read the book
>> closely <<!!!

Thanks for the help - that worked perfectly.

Happy holidays.