igel74
November 10, 2002, 5:37am
1
Hello,
i try to put the callback funktion in a class, this function uses the class. The class ist binding the function to glut to.
Have anybody an example of this situation?
Regards,
igel74
example:
…
//Bind “handle_resize” to glut
void inithandler()
{
glutReshapeFunc(handle_resize); //won´t work
}
…
//resize
GLvoid handle_resize(GLint width, GLint height)
{
if (height == 0) height=1;
if (width == 0) width=1;
transform(); //another class member
}
Originally posted by igel74:
[b]Hello,
i try to put the callback funktion in a class, this function uses the class. The class ist binding the function to glut to.
Have anybody an example of this situation?
Regards,
igel74
example:
…
//Bind “handle_resize” to glut
void inithandler()
{
glutReshapeFunc(handle_resize); //won´t work
}
…
//resize
GLvoid handle_resize(GLint width, GLint height)
{
if (height == 0) height=1;
if (width == 0) width=1;
transform(); //another class member
}[/b]
Check out “AtlAux” on google. There’s a class
in it that allows you to send functional callbacks to a class method.
Regards,
Jim
– http://www.mathies.com/glfaq/
[This message has been edited by jmathies (edited 11-18-2002).]
147-2
November 18, 2002, 10:41am
3
Your handle_resize(int, int) function is redefined by the compiler to be handle_resize(YourClass&, int, int). The only way to get around that is to make your function static, but that removes you from using variables in the class which are not static as well. I don’t know exactly what you are doing, but when I program such things, for a callback I usually just use a global (C type) function which calls my in-class (C++ type) function.
nigels
November 23, 2002, 3:11pm
4
You may be interested in using or
studying the GLT C++ library that
adapts GLUT callbacks into C++
virtual function calls:
http://www.nigels.com/glt/