Jump to content
  • Advertisement
Sign in to follow this  
raluk22

OpenGL Working with glFfrustum and gluLookAt

This topic is 1948 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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.

Edited by Brother Bob

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!