Problems with gluPerspective()
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?
Quote:Original post by ManaStoneSyntax error ';'? Did you put a ';' at the end of a define?
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?
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;}
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);}
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.
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.
Quote:Original post by Kalidor
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.
Changing the names worked. Thanks.
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.
In VC++ 6.0 the types NEAR and FAR are defined in WINDEF.H. It could be the reason of the error.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement