View Full Version : GLUT in C++
01-22-2007, 01:05 AM
Im beginning in opengl, im using GLUT and I have problems with GLUT callbacks in C++ because GLUT was made for C and not for C++.
┬┐how can i do callbacks in C++ with GLUT?
I have found only one page about it, and i have not understood that at all.
┬┐Is a better choice to use another API like "GLOW" that is an adaptation of GLUT to C++?
thanks a lot.
Callbacks in C++ works just like in C. Pass a pointer to a function you want to be called on an event. There's no difference between C and C++ in that sense.
What I think you actually want is to pass a member function. That, however, won't work. Pointer to functions and pointer to member functions are different, and GLUT doens't know about classes or member fuctions.
Whether some other API is better depends entirely on what YOU want, not what we want. You have to ask that question to yourself, not us. If you want to pass member functions and GLOW supports it, then obviosly it's a better choise. But there are other factors that can be concidered as "better", and that's for you to decide.
01-22-2007, 05:04 AM
Yes, I want to pass a member function of a class and GLUT can't accept that.
01-22-2007, 01:36 PM
You might try creating a singleton class, using static members for the GLUT callbacks, then use virtual functions on the singleton to fire the GLUT events that are raised. You could use this as a base class for your GLUT apps.
01-23-2007, 05:22 AM
That's the solution that I had found, but It seems a hard solution.
I think is a better choice to use GLOW API, the work is done and is easy to use.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.