Jump to content
  • Advertisement
Sign in to follow this  
clearz

Simple Debug Output

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

Hi I am just after starting into the deep and wonderful world of DirectX programming in C++. Up until now the only language I really used was java and a bit of c++ console programming. In java even when you are programming using a GUI the console window is still visible. This is an indispensable tool for debugging where any output can be sent. I am looking to see if this is possible in C++ windows programming. A place where I can send int's, float's and string's for easy viewing during runtime. Does anyone know of a method of doing this./ thanks John.

Share this post


Link to post
Share on other sites
Advertisement
Try the OutputDebugString(), it takes a LPCTSTR but(if you don't know) you can make floats, int etc. to char* like this:

#include <stdio.h>

//Other code

float Angle=1.54f;
char Buffer[1024];
sprintf(Buffer,"Angle is %f",Angle);

//Other code


and then call "OutputDebugString(Buffer);" you need to include "Windows.h" to use OutputDebugString, i suppose you use Windows since you say you are working with DX.

Share this post


Link to post
Share on other sites
Rasmus gave you an excellent answer. I just wanted to point out that OutputDebugString sends its output to the debugger, which ends up displayed in the debug window within the IDE. This is the proper and better way to do it.

If you want to create a console for your Windows application for other purposes, however, use the AllocConsole API (and FreeConsole to clean it up). Again, this is not for debugging purposes.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!