Rendering centered text

How can I render centered text in OpenGL? (in windows, with bitmap fonts created with using wglUseFontBitmaps)

I can’t know the exact lenght of the text. I’ve thought that I could render the text once and check the raster position. But it must be some simpler way.

You may use GetCharWidth32 to store the width of each character in an integer array.
Or, if you still got the HDC in which you selected the font, you could just use DrawText with the DT_CALCRECT flag set.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.