Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


console output prob / debugging poll !

This topic is 6375 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

making a game (not in glut) and i want a console window that I can easily print information to help me debug as I go. I''ve gotten an extra window (of the regular old dos-like variety) to pop up but I cannot for the life of me find a way to print to it. I''m using: WINBASEAPI BOOL WINAPI AllocConsole(); from wincon.h to create the console, but cout and printf don''t work. It compiles but nothing is output. cprintf (as suggested by someone earlier) seems only to exist on macintosh''s (i''m windows, please correct me if i''m wrong though). I''ve also thought that maybe I had to set this new window as default before printf''ing and played around with combinations of functions I thought might work from wincon.h like: SetConsoleCP(GetConsoleCP()); and SetConsoleOutputCP(GetConsoleCP()); but these don''t work either (and i really don''t know what they do) -any advice, asides from using glut? ------------------------------------------- POLL: WHAT''S YOUR TECHNIQUE TO DEBUGGING YOUR PROGRAM AS YOU CODE? (obviously, i''m used to spitting out lots and lots of print statements concerning variable states and specific occurances) ------------------------------------------- (quick apology: i asked about consoles a few days ago but thought problems were solved when i just got the console to appear, oyve)

Share this post

Link to post
Share on other sites
Get the demogl v1.3 sourcecode from http://www.demogl.com. In that sourcecode you''ll find the console class I wrote for DemoGL. The sourcecode also contains a lowlevel debugger you can easily add to your code and then you just have to call simple functions to log messages, return/enter statements etc in a file, including call tree.


Get productive, Get DemoGL: http://www.demogl.com

Share this post

Link to post
Share on other sites

Using AllocConsole, you need to use _cprintf(), note the underscore in front.

Here's my logging macros -

#ifndef _CONSOLELOG_H_
#define _CONSOLELOG_H_


#ifdef _DEBUG
#define LogString(P_message) {_cprintf("%s", P_message);}
#define LogInt(P_message) {_cprintf("%i", P_message);}
#define LogFloat(P_message) {_cprintf("%f", P_message);}
#define LogName(P_message) {_cprintf("[%-20s] - ", P_message);}
#define StartConsole() {AllocConsole(); LogString("Starting log\n");}
#define LogString(P_message) {}
#define LogInt(P_message) {}
#define LogFloat(P_message) {}
#define LogName(P_message) {}
#define StartConsole() {}


It's nice and small (I didn't bother with a StopConsole() macro) and works fine for me. A possible upgrade would be to not only _cprintf() to the the console, but write it to a log file as well.

The source function here in the forum didn't work for this code, it was all stretched out. The #include should be conio.h


Edited by - danbrown on February 2, 2001 2:01:01 PM

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!