output of integers

Hi,
I’m currently using VC++6.0 and opengl for simulation purposes. My current problem is more on Visual C++. I need to output integers on the screen using visual C++ facilities. Can I use TextOut? How do I then convert integer to string? If not TextOut, then what else must I use?
Can I do the same thing using opengl facilities instead of Visual C++?

I always change integer to string like this in ordinary programming:

CString str;
str.Format(" %d",i); // output i
pDC->TextOut(30,40,str);

But I’m not sure if it does work in OpenGL programming for I’m a completely newer in it.

i think there is a command like
wsprintf(…)
which takes an input and returns an formated string as output, i used to take this function (as far i remember)

wsprintf is for 16 bit wide characters (unicode for example).

since you’re only using regular “” (don’t know their name in english ), the function to use is sprintf().

example:

char str[100];
int i=13;
sprintf(str,“%d”,i); // str will have “13”

sprintf will return the number of char’s, and you can use that for error-checking

To output text in an OpenGL window on Windows, you can use wglUseFontOutlines or wglUseFontBitmaps to create a set of display lists–one for each character–using the current font. You then draw the text using glCallLists. Read the documentation for these functions.

Converting an integer to a string is the kind of thing you learn in introductory programming classes. You can use sprintf, as someone mentioned, or the stringstream class to do this. If you don’t know how to do this, I would suggest that you read a book on C++ programming before attempting to use OpenGL.

And don’t forget, if you just want to see the value of a variable in you program, you can always create a console app and use cout or printf.