• Announcements

Archived

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

Nehe bitmap font problems

Recommended Posts

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

Share on other sites
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

Share on other sites
I said im passing a float, it looks like:

glPrint("FPS: %.2f", fps);

I''ve also tried using a double, still doesnt work.

Share this post

Share on other sites
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

Share on other sites
I already said in the original post that i''ve tried ints. It displays zero instead.

Share this post

Share on other sites
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

Share on other sites
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

Share on other sites
No one has an answer for this?

Share this post

Share on other sites
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

Share on other sites
I''ve fixed it now. You were right, jwace, my variable types for calculating the FPS weren''t big enough

• Forum Statistics

• Total Topics
628293
• Total Posts
2981869

• 11
• 10
• 10
• 11
• 17