0
votes

How can I actually declare gluPerspective?

I mean I am drawing a spiral and I am setting z = -50 in the beginning and looping until the circle is complete. So what will be the declaration of gluPerspective?

3
Do you mean "how to use gluPerspective" and not "how to declare"?Jim Buck
What platform? Programming language, operating system, version of OpenGL, etc.Peter Mortensen
thanks guys i got it somehow :)codemax

3 Answers

2
votes

Somewhere at the top of the source file you want to use gluPerspective in:

#include <GL/glu.h>

and then you can use gluPerspective with no problem.

0
votes

I'm not really sure what you mean.gluPerspective() is typically used once when the program starts, then whenever the window is resized, to define the way primitives are projected to the screen.

You do that as so:

glMatrixMode(GL_PROJECTION);                        // Select The Projection Matrix
    glLoadIdentity();                                   // Reset The Projection Matrix
    gluPerspective(60,screenWidth/screenHeight,0.1,1000);
0
votes

I strongly recommend that you have a look at the official OpenGL red book chapter 3, Viewing. There you'll find a good introduction to perspective projection.


Edit after comment:

Well if you would read the chapter carefully you would read this:

You can manufacture a viewing transformation in any of several ways, as described next. You can also choose to use the default location and orientation of the viewpoint, which is at the origin, looking down the negative z-axis.

and

void gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble near, GLdouble far);
Creates a matrix for a symmetric perspective-view frustum and multiplies the current matrix by it. fovy is the angle of the field of view in the x-z plane; its value must be in the range [0.0,180.0]. aspect is the aspect ratio of the frustum, its width divided by its height. near and far values the distances between the viewpoint and the clipping planes, along the negative z-axis. They should always be positive.