Jump to content
  • Advertisement
Sign in to follow this  
ManaStone

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by ManaStone
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?
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!