Unix and OpenGL in C++

Has anyone tried coding OpenGL functions as classes in Unix???

the glut libraries do not accept classes right???
for example in glutIdleFunc(xxx),
xxx cannot be a class right???

Just wish to verify this … because my compiler complains when I use a C++ class with the glut functions. Not sure if it’s because my codes or just because glut functions do not accept C++ class as parameters???

no, openGL and glut will not support classes, because they are not object oriented (so more people can use them).

besides, what you are trying to do doesnt make any sense. why would you pass a class to a function that wants a function pointer? thats never going to work, because there is no way to know which function in the class to call (unless of course, its a class derived from a glut class, but like i said, gl and glut arent OO). what you need to do is something like this

glutIdelFunc(class.method);

im not sure if thats exactly it, you may need to cast it, or make it a pointer, or some such (ive never done this, but i remember my friend had problems trying to do it). but that is the basic idea.

you’re right.

just make a class that own a method for your glut function, and call this method inside this glut function callback. That’s the only way i found for now.

this is not only an unix problem but linux and windows too (and others).
"
for unix and opengl, you may go to linux forum (i don’t know every differences btw linux and unix), but maybe better.
"

JD

Originally posted by Spiral Man:
[b]no, openGL and glut will not support classes, because they are not object oriented (so more people can use them).

besides, what you are trying to do doesnt make any sense. why would you pass a class to a function that wants a function pointer? thats never going to work, because there is no way to know which function in the class to call (unless of course, its a class derived from a glut class, but like i said, gl and glut arent OO). what you need to do is something like this

glutIdelFunc(class.method);

im not sure if thats exactly it, you may need to cast it, or make it a pointer, or some such (ive never done this, but i remember my friend had problems trying to do it). but that is the basic idea.[/b]

this:
glutIdelFunc(class.method);
doesn’t work !!!

maybe doing an glut for c++ !
anyone interrested ?

this:
glutIdelFunc(class.method);
doesn’t work !!!

Might work if you define the member function as static. A member function is different from a “regular” function. It has a hidden parameter when called, the this-pointer, that points to the object that called the member function.

A static function does not have this hidden parameter, and is (should be, if I get this correct) like a regular function.

but, we don’t need static members in each time !