PDA

View Full Version : perspective



true_atlantis
09-13-2005, 03:12 PM
i have only been working in 2d views, could anyone give me a code that will just have lines for the 3 axis shown from a perspective far away? so the image looks something like this...

__________
| |
| |/_ |
|________|

thanks

Ehsan Kamrani
09-13-2005, 09:00 PM
Hi. Change your reshape function:

GLvoid ReSizeGLScene(GLsizei width, GLsizei height)
{
if (height==0)
{
height=1;
}
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(54.0f,(GLfloat)width/(GLfloat)height,0.1f,1000.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

-Ehsan-

true_atlantis
09-13-2005, 09:29 PM
see, that doesnt work for me... like i initially said, can someone give me a complete code that i can compile that will give me a perspective view of the axis. for example, a line from 0,0,0 to 0,0,300 0,300,0 and 300,0,0 with the glOrtho of 0,300,0,300,0,300 looking from 500,500,400 at 0,0,0

does that make sence?? right now i have a program that has 3 different views, looking donw all the axis, i want a third window to be an 'animate' window which will just revolve the camera, showing the whole world... thanks

memfr0b
09-13-2005, 11:43 PM
/* setup camera */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(fovy, aspect, znear, zfar);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(
fromx, fromy, fromz,
0, 0, 0,
0, 1, 0
);

/* draw axes */
glBegin(GL_LINES);
glColor3f(1, 0, 0);
glVertex3f(0, 0, 0);
glVertex3f(1, 0, 0);

glColor3f(0, 1, 0);
glVertex3f(0, 0, 0);
glVertex3f(0, 1, 0);

glColor3f(0, 0, 1);
glVertex3f(0, 0, 0);
glVertex3f(0, 0, 1);
glEnd();