problem with c++ opengl

i use opengl for c++ 6.0
please show me how to close opengl window and keep console window. not exit program. the program will be countinue.

I’m no expert, but why don’t you try to hide the opengl windows instead of closing it?

but i need my program will be countinue.
ex:
main()
{
draw by opengl;
printf(“abc”);
}
the program will be only draw in opengl;
after call fucntion draw in open gl, the compiller stop in that line.
the program do not print “abc”;
because i want do many lines below the function draw in opengl. how?
please help me.

below function glutMainLoop();
every line do not run;
why?

Do not use glut, use something more low level to be able to create/destroy a window while the program runs.

glutMainLoop() is known to not return to the caller. You can use freeglut (google for it), which includes an iterable glutMainLoop(). But of course, you’ll have to compile it yourself which may not be easy for you.

I’m with ZbuffeR; it sound like you want to use a windowing system more flexible than GLUT. GLUT was really designed more for very quick and dirty single-window test programs than for anything “real world” like the application you’re describing. There are dozens of worthwhile alternatives to consider; the one I know best is wxWidgets, but they should all work more or less equally well.

Maybe he wants to test something and for that glut is ok.

If all you want is to examine what’s displayed in the GLUT console window, Google for the _kbhit function; you’ll need to #include <conio.h> and use something like this (at the very end of main):

printf ("Press any key to exit... ");

while (1)
{
	if (_kbhit ()) break;
	Sleep (5);
}

Sleep (5) is optional here, and you’ll need windows.h for it. All it does is prevent your program from using 100% CPU while it’s waiting for you to press any key. It’s a Windows API function but you can use it in non-GUI code just as easily as in GUI code.

Out of curiosity, what’s wrong with printing to the console window before closing the graphics window? I do this all the time. It’s a good way to debug.