0

I am trying to specify the glutClosefunc for the tutorial at http://www.glprogramming.com/red/index.html but it doesnt seem to work...

my code looks like this:

int main(int argc, char* argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(250,250);
    glutInitWindowPosition(100,100);
    glutCreateWindow("hello");
    init();
    glutDisplayFunc(display);
    glutCloseFunc(close);  //This isnt working
    glutMainLoop();
    return(0);
}

Its currently coming up with freeglut ERROR: function called without first calling 'glutInit'

The code example was a C example... i converted the parameters in main to C++, but i didnt change glutInit...

oh yeah, you can see i am using freeglut instead of glut like the tutorial says as well

Da_Boom
  • 65
  • 1
  • 6
  • Are you sure that glutCloseFunc is what's causing the error message, and not glutMainLoop? It seems odd that you'd call the close function before the main loop function. – user673679 Apr 16 '14 at 10:55
  • no I have now realised that not only does glutCloseFunc does the error, but whenever i use glutLeaveMainLoop, i get the same error and commenting out the glutInit() call dosent change the situation... the game still runs, and it still comes up with the same error... i think my freeglut might be a dud... i will check that... – Da_Boom May 26 '14 at 07:40
  • ok updated freeglut.. still a no go – Da_Boom May 26 '14 at 07:57

1 Answers1

1

Ahh I figured it out.. I had, in my linker input, linked to glut32.lib instead of freeglut.lib and therefore freeglut wasnt initializing properly!

Da_Boom
  • 65
  • 1
  • 6