In the Win32 console, the standard OpenGL process is as follows:
Int main (INT argc, char * argv [])
{
Gluinitwindowsize (500,250 );
Gluinitwindowposition (140,140 );
Fig );
Gluinit (& argc, argv );
Valley createwindow ("Demo ");
Glclearcolor (1.0, 1.0, 1.0, 1.0 );
Gludisplayfunc (Display );
Glureshapefunc (reshape );
Glumousefunc (Mouse );
Glumotionfunc (motion );
Glukeyboardfunc (key );
Glumainloop ();
Return 0;
}
In the dialog box program of MFC, using such a process may cause memory leakage. The reason is thatGLutmainloop ()The normal process of the system is blocked. After the window created by the glucreatewindow () is closed, the glumainloop () directly exits the program with exit (0) instead of executing the statements after the glumainloop, this makes the release and Resource Recycling of some classes impossible, resulting in Memory leakage. There are three ways to correct this problem:
1. Use gluleavemainloop () instead of glumainloop ().
2. process the exit (0) part of the code.
3. Set the following parameters before applying the Keyword:
Glusetoption (maid, FIG );
Then, the following code is executed.
The above method can effectively deal with Memory leakage caused by glumainloop!