-
writing numbers on the screen
Hi,
I want to display a set of 3D (float) coordinates on the screen. I know you can use glRasterPos and glutBitmapCharacter to display a character but I am lost on writing float values. Any help is appreciated.
-
Member
Regular Contributor
Re: writing numbers on the screen
I don't know, but if you can display any character, can you do something like this:
float x;
char *ptr;
char buf[1024];
x = 3.14 (etc...)
sprintf(buf, "%f", x);
for(ptr = &buf[0]; ptr; ptr++)
{
display_gl_char(*ptr);
}
-
Re: writing numbers on the screen
use sprintf()
this is what I got to work...
char str[] //storage for string
sprintf(str, "myfloat: %f", outputVar);
glRasterPos2f(-50, -50);
len = (int)strlen(str);
for (i=0; i<len; i++)
{
glutBitmapCharacter(hudFont, str[i]);
}
[This message has been edited by mike j (edited 02-24-2000).]
-
Member
Regular Contributor
Re: writing numbers on the screen
Wait a minute. That line has to be:
for(ptr = &buf[0]; *ptr; ptr++)
(Test for null at end of string)
-
Re: writing numbers on the screen
Thanks alot mikej and nickels.
glguru
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules