How to hide/show console window when using glut

As the subject, How to hide/show console window when using glut. Thanks :slight_smile:

Hmm, I just mentioned that in another post…

On Win32, the presense of the console window is determined whether you link /subsystem:CONSOLE or /subsystem:WINDOWS. There is no way I know of to make the console window disappear or reappear once the app is compiled that way.

If you are using Visual C, you must exlicitly change the name of your GLUT app’s entry point from main() to WinMain(). If you are using Watcom C, the linker will implicitly resolve the entry points if the app uses only main().


Actually on Windows you should be able to remove the console quite easily

See the function FreeConsole(); its part of the standard SDK Api you need to include Windows.h.

Thanks a lot!
FreeConsole/AllocConsole are ok.

I’ve had success with this:

HWND hWnd = GetConsoleWindow();

I like to move the console to the upper-left corner of the screen, so I can see all my errors as they scroll by :slight_smile:

Most compilers, including Watcom, CodeWarrior and Borland, have an option for the type of target you are building.

In the OpenWatcom IDE, you can specify your target to be a Windowed application from the “Target” menu, selecting “Rename Target…”, or use the “-zw” switch, if you compile from the command line.

I can only assumes similar functionality is available for whichever compiler you are using, even if you use a “main ( argc, argv )” as your entry point.

Or you could do it the easy way and include this in your code somewhere :smiley:

#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )