title: Using OpenGL glutDisplayFunc within class
body: <p>I've created a C++ class (<code>myPixmap</code>) to encapsulate the work performed by the OpenGL GLUT toolkit.  The <code>display()</code> member function of the class contains most of the code required to set up GLUT.</p>
  
  <pre><code>
  void myPixmap::display()
  {
      // open an OpenGL window if it hasn't already been opened
      if (!openedWindow)
      {
          // command-line arguments to appease glut
          char *argv[] = {"myPixmap"};
          int argc = 1;
          glutInit(&argc, argv);
          glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
          glutInitWindowSize(640, 480);
          glutInitWindowPosition(30, 30);
          glutCreateWindow("Experiment");
          glutDisplayFunc(draw);
          glClearColor(0.9f, 0.9f, 0.9f, 0.0);
          glClear(GL_COLOR_BUFFER_BIT);
          glutMainLoop();
  
          openedWindow = true;
      }  
  }
  </code></pre>
  
  <p>The display function passed to <code>glutDisplayFunc()</code> is another member function of the class:</p>
  
  <pre><code>
  void myPixmap::draw(void)
  {
      glDrawPixels( m,n,GL_RGB,GL_UNSIGNED_BYTE, pixel );
  }
  </code></pre>
  
  <p>However, gcc 4.2.1 on Mac OS X 10.6.4 refuses to compile this code, claiming that:</p>
  
  <p><code>
  argument of type 'void (myPixmap::)()' does not match 'void (*)()'
  </code></p>
  
  <p>Is there a way to use the GLUT toolkit inside a member function of a class, or must I call all GLUT functions within the <code>main</code> function of the program?</p>