• Create Account

## Working with glFfrustum and gluLookAt

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

2 replies to this topic

### #1raluk22  Members

102
Like
0Likes
Like

Posted 23 May 2013 - 11:35 AM

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.

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);
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);
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!

### #2Brother Bob  Moderators

10104
Like
0Likes
Like

Posted 23 May 2013 - 12:14 PM

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, 23 May 2013 - 12:15 PM.

### #3raluk22  Members

102
Like
0Likes
Like

Posted 23 May 2013 - 12:39 PM

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.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.