I have a program that reads a 360 mono panorama and reads an IMU, drawing the correct part of the panorama based on the head location.
I am creating two windows, one per display, and do not want to rely on GLUT_STEREO. The draw() calls for each display are therefore independent, but right now they render the same thing, which is a gluSphere to represent the panorama. To draw the correct part of the sphere, IMU data (quaternion) becomes a rotation matrix, and that matrix is multiplied with the projection.
I wish to create a little bit of overlap with the two images, as shown with the following image:
For example, the red rectangle is my left display and the blue rectangle is my right display, but there is some overlap in the middle.
I was reading some article about stereo rendering, and I thought the solution would be to replace the call from gluPerspective() to glFrustum(), and simply modify both the left and right parameter at the same time. I thought subtracting some value to left/right parameter of glFrustum() on the display and adding some value to the left/right parameter of glFrustum() would do the trick. I modified the glutReshapeFunc() callback's projection matrix to do just that:
void resize(int width, int height)
{
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
GLdouble near = 0.1;
GLdouble far = 100.0;
GLdouble aspect = (double) width / (double) height;
GLdouble top = tan(FOVY / 360 * M_PI) * near;
GLdouble bottom = -top;
GLdouble right = top * aspect;
GLdouble left = -right;
// TODO: Canned value for testing
left += 0.5;
right += 0.5;
glFrustum(left, right, bottom, top, near, far);
// gluPerspective(FOVY, aspect, near, far);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
Unfortunately, this does not do what I expect (and I am really not sure why). I would think modifying both left and right parameter of glFrustum() would keep the same horizontal FOV but move it to the left or right. It seems to either stretch the image in or out.
I have played around with glTranslatef() on the ModelView or glLookAt(), but there place are not clear to me. Why is glFrustum() not having the right behavior please, and what am I missing?