On Sat, Oct 4, 2008 at 11:59 PM, Patrick Mullen <[EMAIL PROTECTED]>wrote:
> Ian Mallet: "Mallett" ;-) > > I'm running into random troubles with PyOpenGL transparency again, and > the simplest solution is just to make the textures have > > transparency. Normally, I would just add the transparency in an image > editor, but unfortunately I have ~250 images. My solution is > > programming! I wrote a script which should convert all the images to be > ~50% transparent: > > Well, here is how you can fill a surface with alpha values in pygame: > > import pygame > screen = pygame.display.set_mode([400,400]) > img = pygame.Surface([400,400]).convert_alpha() > img.fill([255,255,255]) > array = pygame.surfarray.pixels_alpha(img) > array[:,:] = 50 > del array > pygame.image.save(img,"test.png") Cool, this works. Thank you. > surface.set_alpha does NOT fill the surface with alpha values, all it > does is tell the rendering system to mix the colors when it blits the > surface. This is why it won't save those values. OK. > But what trouble are you having with transparency in pyopengl? If you > use glColor to set an alpha value, you should get the same effect. > And it will be more flexible too, such as allowing you to handle > things fading in etc. Although I don't know what your problem space > is. But if you are having issues such as objects that should be in > front displaying behind etc, I don't think making the textures have > alpha is going to fix the problem. I think we should look at the > original problem instead of trying to work around it. Naturally, that was my original ideology--simpler is better. I look for causes of bugs, not workarounds. Of course, in this case, the problem is more complex--the texture is to be mapped onto a surface which will be shadowed by at least three lights casting three separate shadows onto a single object via a total 9-pass shadowmapping algorithm. Whew. So much for simple... It's actually not as weird as that sounds, and I'm sure it could be done in PyOpenGL, but in this case, I think the simpler solution is just to load the transparency in the transparency channel. In short: the texture could be made transparent through PyOpenGL, but that makes it more complex... So, thank you very much, everyone! Ian