int score = 0;
glRasterPos2f( 5.5f, 5.5f); // text position
glPrint(score); // dispay score
When I compile this I get an error saying that It can''t display the int score then something to do with a char...
Theres obviously a way around this problem but I can''t figure it out! I know it must have something to do with the glPrint function but what!....
Hope somebody can help
Thanks in advance
Alan
IF YA SMELL... WHAT THE BEZZ IS COOKIN''''
Printing Text Problem
Hi,
Im making a game and I want to set up a score thing.... I have the text that says player 1 then I want it to display the score heres what I put in..
you can make it like this:
glPrint("%7.0f", score);
%means that there is something not to print behind it, 7 means 7 digits before the dot and 0 nothing behind the dot, and f that it is a float...
glPrint("%7.0f", score);
%means that there is something not to print behind it, 7 means 7 digits before the dot and 0 nothing behind the dot, and f that it is a float...
u wouldnt understand a german quote :)
I put in
int score = 0;glPrint("Player 1: %7.0f", score);
Put It does not work..... It just displays "Player 1:" but no score
Does anybody have an other idea
Alan
IF YA SMELL... WHAT THE BEZZ IS COOKIN''''
use sprintf. something like this
{
char scorestr[32];
int score = 0;
sprintf(scorestr, "Player 1: %i", score);
glPrint(scorestr);
}
Im assuming you know how the printf functions work as far as formatting goes. If you dont, check msdn or ask...
{
char scorestr[32];
int score = 0;
sprintf(scorestr, "Player 1: %i", score);
glPrint(scorestr);
}
Im assuming you know how the printf functions work as far as formatting goes. If you dont, check msdn or ask...
Yea, both %d and %i will give you the same value.
I just use %d, ''cause it make me think more of a decimal value.
I just use %d, ''cause it make me think more of a decimal value.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement