PDA

View Full Version : numbers to screen



phil67rpg
03-19-2006, 10:46 PM
how do you output numbers to the window, I can print text but need numbers for scoring in a game

songho
03-19-2006, 11:54 PM
I think you are asking how to convert a number to ASCII characters(string). It is not OpenGL question, but in C, use sprintf(). And use stringstream for C++. Then get the number as string by stringstream.str().c_str().

int score = 100;
stringstream ss;
ss << score << ends;

// your drawing function look like this
drawMyString(ss.str().c_str(), posX, posY, color, font);