PDA

View Full Version : GLUT multiple viewports



vladtep
04-28-2009, 02:52 AM
hi there,

actually i have a bunch of problems here with creating a scene with multiple viewports. should look like a 3dsmax window or any other 3D modelling tool.

this is the first part of my reshape function and well it SHOULD do all that stuff but actually it doesn't and gluLookAt doesn't work at all.



// normal mode
if(!divided_view_port)
glViewport(0, 0, w, h);
else
{
// right bottom
glViewport(w/2, h/2, w, h);
glLoadIdentity();
gluLookAt(5.0f, 5.0f, 5.0f,
0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f);

display();

// left bottom
glViewport(0, h/2, w/2, h);
glLoadIdentity();
gluLookAt(5.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f);

display();

// top right
glViewport(w/2, 0, w, h/2);
glLoadIdentity();
gluLookAt(0.0f, 0.0f, 5.0f,
0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f);

display();

// top left
glViewport(0, 0, w/2, h/2);
glLoadIdentity();
gluLookAt(0.0f, 5.0f, 0.0f,
0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f);

display();
}


After this viewport thing I'm defining this. Well this code is given. Actually I don't really know why I have to use it but it doesn't work without.



glMatrixMode(GL_PROJECTION);
glLoadIdentity();

if (w <= h)
glOrtho(-2.0, 2.0,
-2.0 * (GLfloat) h / (GLfloat) w, 2.0 * (GLfloat) h / (GLfloat) w,
-10.0, 100.0);
else
glOrtho(-2.0 * (GLfloat) w / (GLfloat) h, 2.0 * (GLfloat) w / (GLfloat) h,
-2.0, 2.0,
-10.0, 100.0);

glMatrixMode(GL_MODELVIEW);


After adding the correct geometry values and control functions i can rotate the construct as you can see here:

http://img518.imageshack.us/my.php?image=scene.jpg

This picture shows me the construct looking from a positive z axis value. I have no idea why nothing is working here.

Brolingstanz
04-29-2009, 02:30 PM
For one thing the top left gluLookAt looks suspect.

I would suggest you avoid lookat unless you know how it works.