Working with glFfrustum and gluLookAt

Started by
1 comment, last by raluk22 10 years, 11 months ago

Hello everybody!

I just started working with OpenGL and I have this problem with glFrustum and gluLookAt. I have to obtain the first image but the best I could get was the second.

frustum.png

As you can see I need to get a 1 point perspective, but no matter how I tried I can only get the 3-point perspective on that cube. I read quite a few tutorials and posts about frustum and gluLookAt but none would work for me and I've been stuck on this for 2 days now.

This is my code so far:


glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glFrustum(-5, 5, -5, 5, 5, 100);
  gluLookAt(7,7,10,0,0,0,0,1,0);

 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glPushMatrix();
      DisplayAxe();
      DisplayObiect(); //displays the cube
    glPopMatrix();
 

The cube is of side 5.

Now if anyone could help me or at least give me a hint on how to use glFrustum and gluLookAt to get that 1-point perspective it would be awesome.

Thank you!

Advertisement

The view point has to look down the red axis, perpendicular to the plane formed by the greed and blue axes. Then the vanishing points along the green and blue axes are at infinity. Assuming that the red axis is the Z-axis:


gluLookAt(7,7,10,7,7,0,0,1,0);

The view point is now faced along the vector (7,7,0) - (7,7,10) = (0,0,-10), which is along the negative Z-axis.

The view point has to look down the red axis, perpendicular to the plane formed by the greed and blue axes. Then the vanishing points along the green and blue axes are at infinity. Assuming that the red axis is the Z-axis:


gluLookAt(7,7,10,7,7,0,0,1,0);

The view point is now faced along the vector (7,7,0) - (7,7,10) = (0,0,-10), which is along the negative Z-axis.

Thank you a billion. This totally helps, and I finally got how the gluLookAt function works. I had a pretty different idea about the whole thing. Thanx again.

This topic is closed to new replies.

Advertisement