Problems with gluPerspective()

This topic is 4811 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Anytime I try to use gluPerspective() in a function where I pass the function arguments into zNear and zFar I get the error “syntax error : ';'” Is this normal for this function and am I supposed to use constants all of the time to get it to work? If so, is there any way around it?

Share on other sites
Quote:
 Original post by ManaStoneAnytime I try to use gluPerspective() in a function where I pass the function arguments into zNear and zFar I get the error “syntax error : ';'” Is this normal for this function and am I supposed to use constants all of the time to get it to work? If so, is there any way around it?
Syntax error ';'? Did you put a ';' at the end of a define?

like: #define zFar 1000;

You don't need to use constants with it. Since when could a function only take constants?

void gl_video::SetPerspective(float fFOV = 45.0f, float fApsect = 1.33, float fNear = 0.1f, float fFar = 500.0f){    glMatrixMode(GL_PROJECTION);	glLoadIdentity();    gluPerspective(fFOV, fApsect, fNear, fFar);    glMatrixMode(GL_MODELVIEW);    glLoadIdentity();    return;}

Share on other sites
void cGamePerspective::Set3DPerspective(GLint fov,GLfloat ratio,GLdouble near,GLdouble far){	glMatrixMode(GL_PROJECTION);//	gluPerspective(fov,ratio,near,far); does not work	gluPerspective(fov,ratio,1,200); //works 	glMatrixMode(GL_MODELVIEW);}

Share on other sites
Notice that I pass floats, and you pass doubles.

Share on other sites
void cGamePerspective::Set3DPerspective(float fov=45,float ratio=1.33,float near=.1,float far=500.0){	glMatrixMode(GL_PROJECTION);	gluPerspective(fov,ratio,near,far);//does not work//	gluPerspective(fov,ratio,1,200); //works 	glMatrixMode(GL_MODELVIEW);}

Still doesn't work. It still doesn't even work if I try to do it indirectly either. If I fill in the gluperspective parameters with member variables it will work, but then I get syntax errors when I try to make a function that assigns values to the member variables.

Share on other sites
A while ago when I was writing a crappy camera class, if I used member variables named near and far (maybe m_Near and m_Far, I don't remember), visual studio would freak out. It seemed to consider them reserved words for some reason. I changed the variable names to something else and it worked perfectly. I don't see anything from that code snippet that would be wrong, so maybe try changing the variable names? It's a long shot, but maybe that's the problem.

Share on other sites
Then why don't you post the actual error?

Share on other sites
Quote:
 Original post by KalidorA while ago when I was writing a crappy camera class, if I used member variables named near and far (maybe m_Near and m_Far, I don't remember), visual studio would freak out. It seemed to consider them reserved words for some reason. I changed the variable names to something else and it worked perfectly. I don't see anything from that code snippet that would be wrong, so maybe try changing the variable names? It's a long shot, but maybe that's the problem.

Changing the names worked. Thanks.

Share on other sites
Are you using Visual C++?

In VC++ 6.0 the types NEAR and FAR are defined in WINDEF.H. It could be the reason of the error.

1. 1
Rutin
38
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 12
• 14
• 9
• Forum Statistics

• Total Topics
633350
• Total Posts
3011471
• Who's Online (See full list)

There are no registered users currently online

×