First my perspectives are messed up when in 4 viewport mode, they look "squashed" and wrong and I tried to fix it with :
gluPerspective(45.0f, (w/2) / (h/2), 0.1f, 100.0f);
but it's still not working.
Secondly when in 4 viewport mode I want 3 views to be fixed, like top-down, left and front but I'm having some trouble.
I thought this would give me top-down view gluLookAt(0,30,0,0,0,0,0,1,0); but it aint.
Here is my code:
void display(int what){ if(what==5){glViewport(0, 0, w, h); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); ca.lookAt();} if(what==1){glViewport(0, 0, w/2, h/2); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(55,15,-5,0,5,-5,0,1,0);} if(what==2){glViewport(w/2, h/2, w, h); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0,30,0,0,0,0,0,1,0);} if(what==3){glViewport(w/2, 0, w, h/2); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); ca.lookAt();} if(what==4){glViewport(0, h/2, w/2, h); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(15,15,15,0,0,0,0,1,0);} //glMatrixMode(GL_MODELVIEW); //glLoadIdentity(); ////gluLookAt(cos(shared.time) * shared.distance, 10, sin(shared.time) * shared.distance, 0, 0, 0, 0, 1, 0); // Roterar kameran kring origo genom att skapa en ny vymatris varje bildruta ////ca.orbitYaw(0.05); //ca.lookAt(); glClearColor(0, 0, 0, 1); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); drawScene(); glutSwapBuffers();}void viewport(){glEnable(GL_SCISSOR_TEST); if(!divided_view_port) { glViewport(0, 0, w, h); glScissor(0,0,640,480); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f, w / h, 0.1f, 100.0f); display(5); }else{ ////////////////////// bottom left - working glViewport(0, 0, w/2, h/2); glScissor(0,0,w/2,h/2); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f, (w/2) / (h/2), 0.1f, 100.0f); display(1); ////////////////////// ////////////////////// top right - working glViewport(w/2, h/2, w, h); glScissor(w/2,h/2,w,h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f, (w/2) / (h/2), 0.1f, 100.0f); display(2); ////////////////////// ////////////////////// bottom right -working glViewport(w/2, 0, w, h/2); glScissor(w/2,0,w,h/2); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f, (w/2) / (h/2), 0.1f, 100.0f); display(3); //////////////////////// ////////////////////////// top left glViewport(0, h/2, w/2, h); glScissor(0,h/2,w/2,h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f, (w/2) / (h/2), 0.1f, 100.0f); display(4); ///////////////////////////}glDisable(GL_SCISSOR_TEST);glMatrixMode(GL_MODELVIEW);}