PDA

View Full Version : How to View from different angles



nithya
07-20-2003, 08:06 PM
How can a 3d oject be viewd from different angles. for ex if we want the orthographic projection of an oject how can it be drawn?

gvm
07-20-2003, 10:12 PM
hi!
you can set pojection using gluOrtho2d, gluPerspective, gluFrustum. (it's an easiest way)

ex:
// (resize function) this will set current projection
void resize(int width, int height) {
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
float aspect = (float)width/(float)height;
gluPerspective(45.0f, aspect, 0.1f, 100.0f);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

// (drawing function) at start of it
void Draw()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

// gluLookAt will set camera to look from...
gluLookAt(camera.position.x, camera.position.y, camera.position.z,
camera.view.x, camera.view.y, camera.view.z,
camera.up.x, camera.up.y, camera.up.z );

// do your drawings here as always

glFlush();
if(doublebuffered)
SwapBuffers(output_hdc);
}

[This message has been edited by gvm (edited 07-21-2003).]