Archived

This topic is now archived and is closed to further replies.

Spiral

Nehe bitmap font problems

Recommended Posts

Spiral    122
Using Nehe''s code i''ve made an FPS counter for my game. Now, if the fps goes greater than something like 250 (possibly 255, that''ld make sense) it displays "1.#J". Im passing a float to glPrint(), i''ve tried other numbers like unsigned ints, longs etc but all seem to produce the same result. Anyone else have this problem?

Share this post


Link to post
Share on other sites
ATronic    122
And what does your print code look like? It should be:

glPrint("FPS: %d", fps);

Is that what you are doing? If so you should have no problems.

Alex Broadwin
A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."
"The answer is out there."
"Please help, I''m using Windows!"

Share this post


Link to post
Share on other sites
ATronic    122
Why do you need a float for frames per second? Try it with integers and see if the problem goes away.

Alex Broadwin
A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."
"The answer is out there."
"Please help, I''m using Windows!"

Share this post


Link to post
Share on other sites
afterburn    124
This is due to the fact that it is a list base. Displays 0 - 255 chars. Make sure you transform the into a string before trying to display it. Otherwise a it thinks it a literal.

sprintf(Buffer,"%d",fps);
glPrint(Buffer);

Which should resolve the issue.

Share this post


Link to post
Share on other sites
Spiral    122
No, that doesnt work. This code inside glPrint(...) does that anyway:

  

char text[1024];
va_list ap;

va_start(ap, fmt);
vsprintf(text, fmt, ap);
va_end(ap);

Share this post


Link to post
Share on other sites
jwace81    160
Try converting the variables that you are using to calculate the FPS to floats sooner. The problem may be that you are mixing variable types in the calculation, and that is causing the result to not be converted to the correct type soon enough.

jw

Share this post


Link to post
Share on other sites