[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Re: BOUNCE pygame-users@seul.org: Non-member submission from ["David Keeney" <dkeeney@travelbyroad.net>]



> If you need speed, you need to go the textured quad route.  However,
> if you just need to put text on the screen, the following code works for
> me:

Thank you.  I will give this a try.

David

> 
> import OpenGL.GL as ogl
> 
> def drawText(position, textString):
>      font = pygame.font.Font (None, 64)
> 
>      # Sigh.  pygame colors are 0-255 integers
>      textSurface = font.render(textString, True,
>                                (255, 255, 255, 255),
>                                (0, 0, 0, 255))
>      textData = pygame.image.tostring(textSurface,
>                                       "RGBA", True)
>      ogl.glRasterPos3d(*position)
>      ogl.glDrawPixels(textSurface.get_width(),
>                       textSurface.get_height(),
>                       ogl.GL_RGBA, ogl.GL_UNSIGNED_BYTE, textData)
> 
> Hope this helps,
> -a
> 
>