开发者

Is it possible to get the width of a character when using OpenGL bitmap fonts?

开发者 https://www.devze.com 2022-12-22 04:37 出处:网络
I am trying to align my bitmap font text in my OpenGL application but I can\'t find anything on getting the width of each character. This is my renderText function:

I am trying to align my bitmap font text in my OpenGL application but I can't find anything on getting the width of each character. This is my renderText function:

def renderText( self, text, fontFace, position ):
    ..... (omitted code to make post shorter)
    glRasterPos开发者_开发知识库2i( position[0], self.windowSize[1] - position[1] )
    glPushAttrib( GL_LIST_BIT )
    glListBase( self.fonts[ fontFace ] - 32 )
    glCallLists( text )
    glPopAttrib()
    ......

I create the bitmap font and use glGenList to store it.

    self.fonts[ fontFace ] = glGenLists( 96 )
    font = win32ui.CreateFont( fontProperties )
    font = hDisplayContext.SelectObject( font )
    wglUseFontBitmaps( displayContext, 32, 96, self.fonts[ fontFace ] )

Anyone know if it's possible to get the character widths or even just the final rendered text's total width?


glutBitmapWidth, glutBitmapLength — returns the width/length of a bitmap character/string.

Python Specification:

glutBitmapWidth(font, character) -> None
glutBitmapLength(font, string) -> None
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号