PDA

View Full Version : OpenGL and C++



mike55
11-21-2003, 05:35 AM
Hey all,

Am currently building the basic outline of a castle as part of a pet project. One of the thing that i want to do is that when you press a key, 'A' in this case you get a sort of aerial view of the castle. Have tryed using gluLookAt, but this is not working correctly. Has anyone got any good suggestions. Have included the code that i used.

if (keys['A'])
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluLookAt( 0.3, 2.0, 2.0,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0);

}

Would appreciate any help possible.

Michael O'Donnell

nexusone
11-21-2003, 06:07 AM
Is there any other place you may reset the projection matrix?

Also you should use glulookat in the Model matrix.

try using variables to set your, would look sometime like this:

// display routine
glMatrixMode(GL_PROJECTIOM);
glLoadIdentity();
glOrtho/Prespective

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt( eye.x, eye.y, eye.z,......);


//Keyboard

if (key == 'A')
{
eye.x = 0.3;
eye.y = 0.5;
eye.z = 0.7;
etc.....



Originally posted by mike55:
Hey all,

Am currently building the basic outline of a castle as part of a pet project. One of the thing that i want to do is that when you press a key, 'A' in this case you get a sort of aerial view of the castle. Have tryed using gluLookAt, but this is not working correctly. Has anyone got any good suggestions. Have included the code that i used.

if (keys['A'])
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluLookAt( 0.3, 2.0, 2.0,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0);

}

Would appreciate any help possible.

Michael O'Donnell