Jump to content
  • Advertisement
Sign in to follow this  
DarkDemon

OpenGL Argument list...

This topic is 3475 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

Hello, I was wondering if anyone can point me in the right direction with this problem. Basically I have a viewer class which setups an opengl context and calls functions like reshape inside the viewer class, the problem is I keep getting errors like this for example. Error 1 error C3867: 'Viewer::Reshape': function call missing argument list; use '&Viewer::Reshape' to create a pointer to member Stems from this line in this method
void Viewer::GLInit(){
 //gl stuff here etc
  glutReshapeFunc(Reshape);
}


Reshape function
void Viewer::Reshape(int w,int h){

  glViewport(0,0,(GLsizei)w,(GLsizei)h);
  glMatrixMode(GL_PROJECTION);
  WinWidth=w;
  WinHeight=h;
  mycamera->SetValuev(POSITION,eye);
  mycamera->SetValuev(AIMAT,aim);
  mycamera->Render();

}


And that function is prototyped like so in viewer.h
void Reshape(int w,int h);

Is there anyway to get around this I tried
  glutReshapeFunc(&viewer::Reshape); 

But no luck.

Share this post


Link to post
Share on other sites
Advertisement
You can't do that.

Assume for a second (and the sake of intellectual curiosity) that you could. So, you call glutReshapeFunc(Reshape) which somehow manages to register the non-static function Reshape of the Viewer function with GLUT.

You're feeling in a schizoid mood, so you create two instances of the Viewer class: goodViewer and evilViewer.

Then, GLUT decides a reshape has happened and therefore calls the Reshape function.

Question: what would "this" point to, inside the Reshape function? The goodViewer instance? The evilViewer instance? How would GLUT know which object the member function should be called from?

Back to reality: glutReshapeFunc expects a function. A function is something which you can call by providing the appropriate arguments. So, if you pass it an argument Reshape, it expects to be able to call Reshape(x,y): this is the entire point of passing a function.

However, Reshape is a member function. A member function is something which you call by providing an object and the appropriate arguments. So, the only way of calling Reshape is to use the object.Reshape(x,y) syntax: the Reshape(x,y) syntax that glutReshapeFunc uses doesn't work, which is why your code cannot work.

Use either a non-member function, or a static member function, as an argument to glutReshapeFunc.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!