View Full Version : output of integers
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++?
09-14-2002, 12:10 AM
I always change integer to string like this in ordinary programming:
str.Format(" %d",i); // output i
But I'm not sure if it does work in OpenGL programming for I'm a completely newer in it.
09-14-2002, 12:19 AM
i think there is a command like
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 http://www.opengl.org/discussion_boards/ubb/smile.gif), the function to use is sprintf().
sprintf(str,"%d",i); // str will have "13"
sprintf will return the number of char's, and you can use that for error-checking
09-14-2002, 06:06 PM
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.