PDA

View Full Version : perspective projection



OGforever
11-27-2005, 05:29 AM
Hello

I'm using glut (unix & c)
I'm trying to figure out how
to draw a 3d model from an OFF
file I've got (it stores coordinates
to polygons that may be connected)
It is to be made from the basics
with lines and polygons and perspective
projection

I'm looking on how the program should
be initialized to be able to draw the
primitives...

If I use GLUT still I need some GL commands
, right? And I wonder, what is need to be
done before start drawing, just to get an idea..
What are the most important commands?

Thanks
OG Regards

11-27-2005, 08:24 PM
I'm not exactly sure as to what you want, but this is how you would setup a perspective projection in GL:

void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity();

gluPerspective(40.0, // FOV ( angle in degrees )
(GLfloat) w/(GLfloat) h, // width/height ration
1.0, // near plane
20.0); // far plane

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

Please register the callbacks in main(...):

glutReshapeFunc(reshape);