Game Development Community

Split screen

by Luis Anton · in Torque Game Engine · 07/22/2004 (8:58 am) · 5 replies

Hi!

I need to create some split screen effect, a vertical one. However, what I really need is to follow these steps:

1) draw the scene, in a 'normal' resolution, say 800x600
2) resize the frame to it's half height: 800x300 and put it at 0,0
3) draw the scene again, from a different point of view, at the same resolution (800x600)
4) resize the new frame to it's half height: 800x300 and put it at 0,300.
5) show the whole thing

Get the idea? We are trying stereo using vertical frame, so I need to do those changes in resolution to conserve vertical proportions. I was using two GuiViewport, one at (0,0) and another at (0,300), but it's not the same effect. GuiViewport draws according to it's own FOV, and it won't change proportions.

Is there something like glResizeFrameAndPutItHere after gClientSceneGraph->renderScene()? :)

See you

#1
07/22/2004 (11:46 am)
Well, I found a solution.

First, set up two GuiViewport, as I said before, one over the other.

Then, using gluPerspective, in SceneGraph::renderScene, does the trick:

dglGetFrustum(&left, &right, &bottom, &top, &nearPlane, &farPlane);
   dglGetViewport(&viewport);
[b]
   nearPlane = 0.1;
   farPlane = 1500;
   top = nearPlane * tan(50 * M_PI / 360.0);
   bottom = -top;
   left = bottom * 1.333333333;
   right = top * 1.333333333;
[/b]

   TextureHandle envMap = NULL;
   if (getCurrentSky() != NULL)

Well, values are hardcoded (50 is the FOV, 1.333333 the aspect: 800/600), but the code added after dglGetViewport simulates gluPerspective. Those new values will be used afterwards, in a glFrustum call.

Hope it helps... if someone needs this or something similar someday :)
#2
10/20/2004 (9:59 am)
How would this technique apply to three or four player split screens? I'm afraid I'm not familiar enough with the API to understand exactly what you're doing let alone extend it to more then two views...
#3
10/20/2004 (10:33 am)
You'd set up three or four viewports. You'd want to make sure that if it were three, that you have it be the same size as the other two. Otherwise they would have an extended field-of-view and an unfair advantage.

Here's the original resource for GuiViewPorts.
#4
07/09/2006 (3:04 am)
How do you add a new GUI viewport?
#5
09/19/2006 (9:39 pm)
Yeah I wana know that two,is it mean that 2 player can play using the same pc,you know like the old car racing games