Sign in to follow this  

text output, with a win32 application Vis studio C++ 2003

This topic is 4590 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 everyone, ive just recently started getting into game developing , working on a turn based strategy futuristic capture the flag, right now. I learned C++ from university, and there we were always using a console based application. One of the most invuable bug fixing tools was outputting certain variables to the screen and tracking their progress to see unexpected behaviour using an output stream or printf. Im using visual studio.net 2003, C++, windows application, SDL libray for my graphics and im curious if there is any way I can use printf or some other mechanism to print out text to the screen? I figure I could load in a font bitmap, and blit certain characters to the screen, and create a fairly subtantial peice of code to set an equivalent to printf up graphically, but is there another simpler alternative? For example, could I get a console window as well as a graphics window?

Share this post


Link to post
Share on other sites
Yes, since you are using SDL, when you create a Win32 Console project, you will get a console window + the SDL graphics screen. If you want to go to the console, you can use printf, cout, etc... if you want to go to the SDL window, then you need to use a font library or something to do as you have said, get a character and blit to the screen. Take a look at the "SDL Text Input" framework in my sig, I think it has everything you need.

It was made to show getting text input and displaying it to the screen, based on what you type, but the principles are still there for font drwaing to the SDL screen. That font code is from Cone3d's Lesson 4. If you have any other questions feel free to ask! There are also other ways of doing this, for exmaple with OpenGL and SDL, which that link is in my sig as well. I plan to eventually comment that code to make it more understandable [wink]

Share this post


Link to post
Share on other sites
Hi,
- You could use sprintf() from stdio.h to write whatever you want into a
buffer.. and then output it to your window using TextOut().
Ex:
sprintf(buffer,"hi foo = %d",foo);
TextOut(hdc,100,50,buffer,strlen(buffer));
or
You could use message boxes like so:
MessageBox(hwnd, buffer , "MessageBoxTitle", MB_OK);
or
You could even use DrawText()... there are a quite a few ways....
Also you could open a file stream and use that as a Log file to your
program.

Anyway, I hope I helped in some way.

v-EktOr -->

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
i mostly use MessageBox() in combination with sprintf()

Share this post


Link to post
Share on other sites
hmmm... I didnt select "console based application" I selected win32 windows application so I dont have any console to work with, just the SDL graphics screen.

About the "messagebox" function, I checked through the SDL documentery and couldnt find that. I assume it is a build in C++ library function, why would that make it print out to the screen, I thought the librarys had zero graphic functionality?

Share this post


Link to post
Share on other sites

This topic is 4590 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this