split screen - how camera work?

i have make a split program using opengl with glut library… the problem is, how did the camera works in split screen? did it use two camera?

In split screen programs, there aren’t two cameras. Just one camera. The projection is changed to different parts of the screen. Check out tutorial 42 at Nehe.gamedev.net. It explains just that. But I suppose the tutorial is in Win32 and not glut.

Yes, as I found out over the weekend, this is very easy to do. Google for “multiple viewports” or check out the example in the Red book.

You can use two “cameras” if you want to show two different things in your split screens. For example, you might want to show the cockpit view from a plane in one split and the view of the plane from outside in the other:

glViewport(…); // Split 1
// Set up view frustum for cockpit view
// Draw cockpit view

glViewport(…); // Split 2
// Set up view frustum for external view
// Draw external view

that mean if we use two glviewport, so there are two camera…glviewport is our camera…is it true?.. do you have a complete code to refer?

“glviewport is our camera” is not really what’s going on. It’s certainly part of the story, but not the whole story.

glviewport describes the map from normalised device coordinates (NDC) to window coordinates. Every point visible to the camera is projected into a cube defined by +/-1 along each of the axis. points with z=1 in the NDC frame are the furthest away from the camera you can get; and points with z=-1 are the closest to the camera. similarly, points on the plane x=1 are the furthest to the right of the visible field of view. Coordinates undergo a transform in order to turn these NDC into a pixel location on the window. This transformation is specified by glviewport. If the call to glviewport was glViewport(A, B, C, D) then NDC points along the plane x=-1 will be mapped to the pixel column A; similarly points along x=1 will be mapped to column (A+C) (width + offset).

So, you should be able to see that you can indeed define any number of cameras and specify different glviewports to describe how what one camera sees is mapped to different parts of the screen… but glViewport isn’t THE camera: its only part of the whole transformation.

I hope this helps


Check out Nehe tutorial #42 (I think)…it talks about this topic.