   Get text length
  Hi everyone. I'm using OpenGL to draw text on the screen.The font was created with CreateFont function.(NeHe lesson,bitmap fonts).In order to position the text i need to know it's length. How can't i retreive it in pixels or in screen dimensions?Thanks in advance.   
  Not sure exactly how OpenGL fonts work, but if they draw text the same way as GDI, you can use SelectObject to select the font into your HDC, and then GetTextExtentPoint32 to calculate the width of the string.   ;Quote:Original post by Erik RufeltNot sure exactly how OpenGL fonts work, but if they draw text the same way as GDI, you can use SelectObject to select the font into your HDC, and then GetTextExtentPoint32 to calculate the width of the string.Yep, openGL works this way.   ;Quote:Original post by szecsQuote:Original post by Erik RufeltNot sure exactly how OpenGL fonts work, but if they draw text the same way as GDI, you can use SelectObject to select the font into your HDC, and then GetTextExtentPoint32 to calculate the width of the string.Yep, openGL works this way.It doesn't really, OpenGL doesn't have any form of font rendering. CreateFont is a Windows function, not an OpenGL one. (it is a part of GDI) and wglUseFontBitmaps is a Windows OpenGL extension (not portable).   ;  I tried to use GetTextExtentPoint32 function. It returns wrong string dimensions.   ;  You have to set the font you use with SelectObject. In the Nehe tutorial, the init switches back to the default font immediately. Delete that line, and set back to default only in KillFont.Anyways, this can be used to render fonts in openGL. There are other methods too of course.   