Jump to content
  • Advertisement

Archived

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

LiquidNRG

printf

This topic is 6200 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

I am working on a general purpose engine to develop physics in and I am wanting to either overload or write a new printf function which will output to the output window in Visual Studio instead of the DOS window. Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
look up OutputDebugString in msdn.

Here''s how I use it:

#include
#include
#include
#include
#include

// determine number of elements in an array (not bytes)
#define _countof(array) (sizeof(array)/sizeof(array[0]))


void Trace(char *debugstring, ...)
{
va_list args;
va_start(args, debugstring);

int nBuf;
TCHAR szBuffer[512];

nBuf = _vsntprintf(szBuffer, _countof(szBuffer), debugstring, args);

OutputDebugString(szBuffer);

va_end(args);
}

Share this post


Link to post
Share on other sites
Output window? Assuming you mean what I think you mean, just make a function called writeToScreen( char * pszString, ... ) which calls a text drawing function.

Here is the base for writeToScreen for you.

  
void writeToScreen( char * pszString, ... )
{
char szBuf[ 512 ] = { 0 };
va_list vaArgs;

va_start( vaArgs, pszString );
_vsntprintf( szBuf, 512, pszString, vaArgs );
va_end( vaArgs )

// Now you have your formatted statement in szBuf.

// Call a routine to output it to the screen using something

// like TextOut().

}


Might I suggest you visit http://www.gamedev.net/reference/programming/features/fontengine/

Share this post


Link to post
Share on other sites
Wrap the code in "source" and "/source" tags (in square brackets) as used by hollowMedia above. You can also use < and > for your includes outside the source tags...

Check out the "How do I put links/quotes/images/code/smileys in my posts?" section of the FAQ

Edited by - Krunk on December 26, 2001 8:05:45 AM

Share this post


Link to post
Share on other sites
I don''t think using a font engine would be useful for whatever he''s doinging... What if the program crashed? you''d be F**KED to know what the value of some variable was...

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!