[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Pygame surfaces as PyOpenGL textures?



On Sat, 10 Nov 2001, Pete Shinners wrote:

>Jan Ekholm wrote:
>
>> However, no terrain without trees. Simple trees are easiest to do with a
>> single billboarded texture. It does need to be partially transparent
>> though. So, the problem is how I can get pyopengl to use a texture that is
>> partially transparent. Ideally I'd like to use simple colorkey
>> transparency, i.e. set a color as transparent. That part works nicely
>> in pygame.
>
>
>i've written the "tostring" function so it does/should respect any 
>colorkey. after you've got the image as a string, try this.
>
>   imgstring = pygame.image.tostring(img_with_colorkey, "RGBA")
>   print 'PIXEL:', [ord(x) for x in imgstring[:4]]
>
>this will print you the RGBA values for the corner pixel. assuming it is 
>"transparent" it should get you something like "PIXEL: [255, 0, 255, 0]"

What I get is just:

	PIXEL: [255, 0, 255, 1]

The first pixel should be transparent. When I check all the alpha
components they all seem to be 1 or 0.

        for index in range(len(imagestr)):
           if (index - 3) % 4 == 0:
                print index, ord (imagestr[index])

Seems like alpha is 0 in those areas that were not masked out, i.e. not
magenta. The image is as at: 

	http://www.infa.abo.fi/~chakie/cm/tree.bmp

>maybe check some of the other pixels, and make sure the alpha value is 
>"255" where you expect it to be?

It's never 255, only 1 or 0. I do manage to get it to display the tree ok,
but the whole image is a little transparent, including the magenta. 


-- 
                 "Students?" barked the Archchancellor.
    "Yes, Master. You know? They're the thinner ones with the pale faces?
  Because we're a university? They come with the whole thing, like rats --"
                                         -- Terry Pratchett, Moving Pictures

____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org