# 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.

## 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 on other sites
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 on other sites
Got it, thanks ToohrVyk.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631425
• Total Posts
3000011
×