Front, Top, Side view with glOrtho?
How is it possible to do this? I need to develop a program that displays 3 orthographic views, and a perspective view, but I have no idea how to get get other orthographic views because when I set up an ortho projection it usually just draws x vs y and throws out z. I tried fooling around with gluLookAt but it doesn't seem to work with glOrtho like it does with gluPerspective.
Here is the simple code for the glut display callback.
void myGlutDisplay( void )
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0,300,300,300);
gluPerspective(fov,1,0,100);
gluLookAt(camX,camY,camZ,0,0,0,0,1,0);
glRotatef( rotationY, 0.0, 1.0, 0.0 );
glRotatef( rotationX, 1.0, 0.0, 0.0 );
drawScene();
glLoadIdentity();
glOrtho(-15,15, -15, 15,-10,10);
gluLookAt(0,30,0,0,0,0,0,-1,0);
glViewport(300,300,300,300);
drawScene();
glutSwapBuffers();
}
this produces and orthographic view
with the standard x along the horizontal and
y along the vertical but what if I wanted, say, z along the horizontal
x along the vertical? This is what I have no idea how to do.
hmm, it seems I can simply do rotation, but how do I figure out the proper angles... My program allows me to interactively rotate, and I have a debug msg displaying the value of the parameter, that I'm using to peak to find the proper angle.
You could track the current angles for pitch, yaw, and roll as separate variables and then apply three rotations, one around each axis. User input will change the value of the angles and you will construct and rotate a new projection each frame.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement