Hello. Digging Glut and OpenGL. I compile MinGW:

g++ main.cpp -o main -mwindows glut32.lib -lopengl32 -lglu32 

The program code (used not only this one - all the same problem):

 #include <windows.h> #include <GL/glut.h> void display() { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_LINES); glColor3f(1.0, 0.0, 0.0); glVertex2f(0.25, 0.25); glVertex2f(0.75, 0.75); glColor3f(0.0, 1.0, 0.0); glVertex2f(0.75, 0.25); glVertex2f(0.25, 0.75); glColor3f(0.0, 0.0, 1.0); glVertex2f(0.50, 0.25); glVertex2f(0.50, 0.75); glEnd(); glFlush(); } int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(240, 240); glutInitWindowPosition(100, 740); glutCreateWindow("Test"); glClearColor(1.0, 1.0, 1.0, 1.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); glutDisplayFunc(display); glutMainLoop(); return 0; } 

The bottom line is that the program works well, everything compiles, there are no warnings. But closing the program window (in any way) the process remains to hang in the controller. Therefore, you have to go into the processes every time and cut main.exe there. How to overcome it?

Thank you in advance.

1 answer 1

Therefore, you have to go into the processes every time and cut down the main.exe

If you wait a while, the process does not end?

In general, the answer is that the process should not remain in the memory.

3.090 How can I make glutMainLoop () return to my calling program?

glutMainLoop () A GLUT menu, or a callback handler. If you insist on glutMainLoop (), there is only one way to do so. You need to download the GLUT source and hack gluMainLoop (). Then hacked the version of glutMainLoop ().

  • Traced - 20 minutes have passed, the process hangs ... My English is bad ... - Black Day
  • It is written that 1. glutMainLoop () does not return control back to the program. 2. GLUT itself handles the program termination situation. - gecube 8:50 pm
  • @ Overdose, apparently you need to register an event handler for some event that will do exit (0); - avp