PDA

View Full Version : Seamlessly split image between two displays



Mark Coniglio
01-15-2007, 08:02 PM
I'm attempting to render a single image that can span two monitors. Given an example screen dimension of 320x240, I am setting the viewport like this:

Monitor 1: glViewport(0, 0, 640, 240)
Monitor 2: glViewport(-320, 0, 640, 240)

This produces the result I'm looking for in that as the model moves across the monitors, it looks perfectly aligned at the split.

The issues is that I had to set the viewport width to 640 to make this work -- otherwise if I just offset a 320 horizontal port left or right, the model is clipped.

So, is there a way to translate the viewport without scaling it? (I.e., perform a translation when everything is transformed from normalized device coordinates to window coordinates)?

Thanks in advance,
Mark

P.S. I suppose I could scale all of the coordinates horizontally with the Projection Matrix, but then the perspective will be off, etc., right?

Mark Coniglio
01-15-2007, 08:47 PM
OK -- I think I have answered my own question. In my code for setting glFrustum, I have the following lines to determine the aspect ratio of the screen:

ratio = screenWidth / screenHeight;

If I change this to the following

viewportSizeH = (float) mCamera.screenWidth * mViewportSizeX;
viewportSizeV = (float) mCamera.screenHeight * mViewportSizeY;

ratio = viewportSizeH / (float) viewportSizeV;

Where mViewportSizeX is the horizontal scaling (in this case 2, since I was setting the viewport to double width, as indicated in my original post.)

This code works -- the image is split as expected.

So my final question is this; by setting glViewport with extents that fall offscreen, am I slowing things down because things that won't actually be seen in the window are actually being rendered?

Any further thoughts and suggestions to produce the fastest rendering is appreciated.

Best,
Mark