PDA

View Full Version : how to create 2 Frustums for stereo

11-22-2001, 05:08 AM
Hi,

I'm trying to do a little program in stereo 3D. I create a window that is twice as wide as needed, and the two views (left and right) are rendered insde that window next to each other. Another program makes sure the two views are displayed alternativly.
Now my problem. I cannot create two different frustums.

void setLeftCam(float halfDelta) {

glFrustum(-2, 5, -0.4142, 0.4142, 1, 1000);

glViewport(0, 0, 400, 360);
glScissor(0,0,400,360);

glMatrixMode(GL_MODELVIEW);

// offset camera
x = x + halfDelta*cos(angle);
z = z + halfDelta*sin(angle);

gluLookAt(x, y, z,
x + lx,y + ly,z + lz,
0.0f,1.0f,0.0f);

// back to original location
x = x - halfDelta*cos(angle);
z = z - halfDelta*sin(angle);

[render]

}

void setRightCam(float halfDelta) {

glFrustum(-5, 2, -0.4142, 0.4142, 1, 1000);

glViewport(400, 0, 400, 360);
glScissor(400,0,400,360);

glMatrixMode(GL_MODELVIEW);

// offset camera
x = x + halfDelta*cos(angle);
z = z + halfDelta*sin(angle);

gluLookAt(x, y, z,
x + lx,y + ly,z + lz,
0.0f,1.0f,0.0f);

// back to original location
x = x - halfDelta*cos(angle);
z = z - halfDelta*sin(angle);

[render]
}

With this code only the first Frustum is used for both views. I've tryed a lot of combinations with push and pop matrix but nothing worked. Can somebody help me with this? Tnx!

pythagoras
11-22-2001, 08:35 AM
Maybe I'm missing something, but shouldn't it be:

void setLeftCam(float halfDelta) {

glMatrixMode(GL_PROJECTION_MATRIX);