Reputation: 19
I have looked fairly thoroughly through posts on this and other sites and it seems like most of the answers were from a number of years ago. I'm looking to create a Win32 C++ app that uses OpenGL functionality. Previously I have debugged these programs by porting the significant C++ code functions to a Win32 Console App. At this point I need to be able to debug through output to console window while interacting with the GLUT window. So, what I am looking for is a way to produce two windows from Win32 main - one holding the GLUT functionality (normal Win32), and one holding console output (not native to the Win32 project app). Is this even possible? If not, can someone suggest a link for debugging interactive GLUT programs?
Matt S.
Upvotes: 1
Views: 417
Reputation: 73376
You can add a console to a GUI programme by hijacking the parent's process console or allocating a new one:
if (! AttachConsole(ATTACH_PARENT_PROCESS)) // try to hijack existing console of command line
AllocConsole(); // or create your own.
DWORD nw,nr; // demo with windows native console i/o
char buff[32];
WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), L"Hello Matthew !", 15, &nw, NULL);
This works fine if you do not foresee input on the console.
If you prefer to use stream output instead of native windows console functions, you 'd be interested in this SO question
Upvotes: 3