GLUT for C++ and OpenGL ES

did you ever try to use GLUT with C++? Do you remember the pain of having to make you member function static, so they can be used as a callback? Maybe you also want to create a OpenGL ES2 context if you develop for mobile devices. But although the latest freeglut supports OpenGL3 contexts, you are still out of luck using GLUT here. But there is rescue:

#include <QGLWidget>

class View : public QGLWidget {
public:
 View();  // glutInit
protected:
 void initializeGL();
 void paintGL(); // glutDisplayFunc
 void resizeGL(int width, int height); // glutReshapeFunc
 void keyPressEvent(QKeyEvent *event); // glutKeyboardFunc
};

and thats it. Works with OpenGL2 and OpenGL ES2 and integrates nicely with the Object Oriented approach. As Qt is LGPL today you can also use it in closed source projects and as you see, you can easily migrate from GLUT without changing all your code 🙂