ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> pygame-users
pygame-users
[pygame] PyGame 2D text in OpenGL?
by Jeff Loiselle other posts by this author
Aug 3 2005 8:15PM messages near this date
Re: [pygame] PyGame 2D text in OpenGL? | [pygame] pyweek: okay to plan ahead?
I'm trying to write some 2D text onto the screen using an OpenGL pygame 
display.  I'm having issues with the texture/raster not updating if the text 
is changed.  It will draw one correct image, and then not update it 
afterwards, however I know the functinos are being updated.  This is the 
code I'm trying to make work, I've tried rastering(this code) and texturing 
to a quad, neither was updating correctly.  Any help would be appreciated.

    def test(self):
        textureSurface = pygame.Surface((512,512))
        x,y = pygame.mouse.get_rel()
        title_font = pygame.font.Font(None, 25)

        mouseText = "MousePos x: %s, y: %s" %(x,y)
        print mouseText
        text2 = title_font.render(mouseText, 1, (250,250,250))
        textureSurface.blit(text2, (200,70))
        textureSurface = textureSurface.convert()

        #textureData = pygame.image.tostring(textureSurface, "RGBA", 1)
        #size = textureSurface.get_size()
        #glRasterPos3f(-.2,-.2,-1)
        #glDrawPixels(size[0], size[1], GL_RGBA, GL_UNSIGNED_BYTE, 
textureData)

        textureData = pygame.image.tostring(text2, "RGBA", 1)
        size = text2.get_size()
        glRasterPos3f(-.2,-.2,-1)
        glDrawPixels(size[0], size[1], GL_RGBA, GL_UNSIGNED_BYTE, 
textureData)
 

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved