focus to glut window

I am coding in C not C++. How can I transfer focus to the glut window from the Windows Dos windows? I can do it now by clicking with the mouse in the glut window but would like to just have it happen when the glut window opens. I use glut’s keyboard to stay focused on the glut window.


This is not an answer, but may be an option if you don’t want to have dos window at all:

Q36: How do you avoid the Console window appearing when you compiler a Win32 GLUT application with Microsoft compilers?

A36: Try using the following Microsoft Visual C compiler flags:


These are linker options… if main or wmain are defined, MSVC build a CONSOLE app by default; hence the need for /SUBSYSTEM:WINDOWS. if /SUBSYSTEM:WINDOWS is defined, MSVC expects WinMain or wWinMain to be defined; hence the need to /ENTRY:mainCRTStartup (eg the entry point is the usual C main).

stdout/stderr are [apparently] not “attached”; output via printf is simply “eaten” unless redirected at the command-line or by a parent program.

Information thanks to Jean-David Marrow (

Even though that is not what I’d planned on doing, I’m going to see how I can move the scanf’s and printf’s so they work within the gl window.

Really appreciate your help.