Advertisement

Printing Text Problem

Started by November 21, 2000 03:35 PM
7 comments, last by Bezzant 24 years ago
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..
  
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''''
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...
u wouldnt understand a german quote :)
Advertisement

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...
GLFloat score = 0.0f;
glPrint("Player 1: %7.0f", score);
This works for me:
  int score = 0;glPrint("Player 1: %d",num);  


Advertisement
Wouldn''t glPrint("Player 1: %i", score) work out?
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.
Thanks all, you have helped me a great deal It''s great to see that you are all willing to help out other people

Thanks
Alan

IF YA SMELL... WHAT THE BEZZ IS COOKIN''''

This topic is closed to new replies.

Advertisement