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?
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?
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.
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);
How about you look at the example in my answer to your previous question. If that answer has helped you to move on to this question, could you at least accept it there?
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.