4

I am working on a 3D application, trying to render some text onto the screen.

But if the text is more than 10 characters the FPS drops to 2, its really annoying.

My program uses glutPostRedisplay() function a lot, this is why its slowing down for sure.

Is there any way that i can make my program display font using glutBitmapCharacter() and without any lag.

I am using VC++ 2008, on win7 x64.

PS: i tried installing Freetype for OpenGL in VC++ but finally gave up. I'd also appreciate if i am pointed towards some 'idiots' guide to installing any font library in VC++ 2008.

genpfault
  • 51,148
  • 11
  • 85
  • 139
2am
  • 699
  • 1
  • 7
  • 25
  • I think the problem might be freeglut library. It shouldn't re-render the screen every time you call glutPostRedisplay(). I am experiencing the same issue – BЈовић Apr 21 '13 at 18:36
  • Thanks a lot mate, did u come across any solution for that :) – 2am Apr 22 '13 at 04:20
  • Not call `glutPostRedisplay()` so often :( – BЈовић Apr 22 '13 at 05:48
  • i got the solution, i think so, it worked at least for my program. i had multisample enabled in my code when i called glutInitDisplayMode() as one of its parameteres, i removed it, and i got the FPS back. and i am still calling glutPostRedisplay() as i was calling before. – 2am Apr 22 '13 at 09:23

1 Answers1

1

If you do not need vector font than the easy way for text display is use of bitmap font texture (fixed pitch style). You can create font image by your self by render it from GDI, or edit it manualy in MSPaint ... or download from inet

For simple text i am now using 16x16 pixel font ,... in image organized as array of 16x16 chars (textureshould be square size so you do not need to use of extensions).

with blending you can achieve sprite like chars, and or transparency with glColor you can change color of text and or alpha the best looking text rendering in this way is to use non perspective projection matrix and texture filtering GL_LINEAR.

of course you must code your char and text draw functions but the are not complex (char is simple square quad, you only have to compute texture coordinates from ASCII, and text is single for with call of char and position update)

Spektre
  • 49,595
  • 11
  • 110
  • 380
  • interesting idea you've mentioned about using images as a character, I could put image information in an array and then can retrieve it the way I want them to be. Anyhow, as I mentioned before I solved the problem by removing GLUT_MULTISAMPLE from glut function call. – 2am Aug 05 '13 at 18:42