What is the nicest way to close FreeGLUT?

前端 未结 4 987
北海茫月
北海茫月 2021-01-02 03:49

I\'m really having trouble closing my console application with FreeGLUT.

I would like to know what the best way is to take every possible closing, because I don\'t w

相关标签:
4条回答
  • 2021-01-02 04:36

    Try this method:

    glutDestroyWindow(glutGetWindow());
    
    0 讨论(0)
  • 2021-01-02 04:40

    I use glutDestroyWindow(int handle);

    or

    According to ID: RigidBody at OpenGL forum

    void destroy_window() 
    {
     window_valid = -1;
    }
    
    void display_func() 
    {
     if(window_valid == -1)
       return;
     // draw things
    }
    
    0 讨论(0)
  • 2021-01-02 04:47

    I use this function:

    void glutLeaveMainLoop ( void ); 
    

    There is more information on their sourceforge page but I never used that functionality:

    The glutLeaveMainLoop function causes freeglut to stop the event loop. If the GLUT_ACTION_ON_WINDOW_CLOSE option has been set to GLUT_ACTION_CONTINUE_EXECUTION, control will return to the function which called glutMainLoop; otherwise the application will exit.

    http://freeglut.sourceforge.net/docs/api.php#EventProcessing

    It is safe to use delete on a null pointer, no need to check.

    0 讨论(0)
  • 2021-01-02 04:50

    Thanks to Maarten's post, this works to me:

    glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE,GLUT_ACTION_CONTINUE_EXECUTION);
    

    whenever you want to leave the mainloop without termiante the application use:

    glutLeaveMainLoop();
    

    don't forget to include "freeglut.h"

    0 讨论(0)
提交回复
热议问题