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

[pygame] PyGame Surfaces + Bliting



Ok, I'm trying to use pygame's text generator to make some simple GUI stuff for a game I'm working on.  I've used pygame a bit, but not too much.  I'm having trouble getting a surface/image that I can write to the screen and update.  Heres a bit of code that illustrates my problem:
 
def testLandTexture(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))
 
    #Raster Block 1
    textureData = pygame.image.tostring(textureSurface, "RGBX", 1)
    size = textureSurface.get_size()
    glRasterPos3f(-.2,-.2,-1)
    glDrawPixels(size[0], size[1], GL_RGBA, GL_UNSIGNED_BYTE, textureData)
 
    #Raster Block 2
    #textureData = pygame.image.tostring(text2, "RGBX", 1)
    #size = text2.get_size()
    #glRasterPos3f(-.2,-.2,-1)
    #glDrawPixels(size[0], size[1], GL_RGBA, GL_UNSIGNED_BYTE, textureData)
 
If I use block 1, then I get a nice image, with good looking text, but the text doesn't update.  If I use block 2 then I get text which updates, but its basically just blocks and totally unreadable (I see the length of the text change, so I know it is updating).  And my console output works correctly. 
 
I've also tried texturing an OpenGL quad with the image and I got the same static result as block 1 gives me now.  Any help would be appreciated. 
 
I apologize if this is a double post, I tried using gmane and it didn't work, or the time delay is really long (Tried a couple hours ago).
 
Jeff L.