Re: [pygame] [OpenGL] Text, Transparency and Lists

2006-09-16 Thread Kris Schnee

Richard Jones wrote:

Using the GL_ONE version, I get the ghostly version in the screenshot.
Using GL_ONE_MINUS_SRC_ALPHA, I get a solid sprite all right, but with a
black rectangle around it.


I just noticed your texture loading has:

  tex_data = pygame.image.tostring(tex, "RGBX", 1 )

Why RGBX? You need the alpha channel...


Poof! Changing "RGBX" to "RGBA" immediately makes it work. Thanks!

This probably happened because that line is a distant descendant of some 
line that I copied from a tutorial long ago, without understanding that 
"X" wasn't Alpha.


Kris


Re: [pygame] [OpenGL] Text, Transparency and Lists

2006-09-16 Thread Richard Jones
On Sunday 17 September 2006 12:34, Kris Schnee wrote:
> Richard Jones wrote:
> > Looks like you've enabled blending without specifying a blend function.
> > You'll want something like:
> >
> >glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
> >
> > This indicates to use the texture's alpha channel for the texture imagea
> > and the opposite (one minus) for the ground image.
>
> Thanks, but that doesn't seem to work. When I load the sprite image, I say:
>  ## Set up translucency.
> ##glBlendFunc(GL_SRC_ALPHA,GL_ONE)
>  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
>
> Using the GL_ONE version, I get the ghostly version in the screenshot.
> Using GL_ONE_MINUS_SRC_ALPHA, I get a solid sprite all right, but with a
> black rectangle around it.

I just noticed your texture loading has:

  tex_data = pygame.image.tostring(tex, "RGBX", 1 )

Why RGBX? You need the alpha channel...


Richard


Re: [pygame] [OpenGL] Text, Transparency and Lists

2006-09-16 Thread Kris Schnee

Richard Jones wrote:
Looks like you've enabled blending without specifying a blend function. You'll 
want something like:


   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

This indicates to use the texture's alpha channel for the texture imagea and 
the opposite (one minus) for the ground image.


Thanks, but that doesn't seem to work. When I load the sprite image, I say:
## Set up translucency.
##glBlendFunc(GL_SRC_ALPHA,GL_ONE)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

Using the GL_ONE version, I get the ghostly version in the screenshot. 
Using GL_ONE_MINUS_SRC_ALPHA, I get a solid sprite all right, but with a 
black rectangle around it. The actual sprite-drawing says:


glColor4f(1.0,1.0,1.0,1.0)
glBindTexture(GL_TEXTURE_2D,self.texture)
glEnable(GL_BLEND)
glBegin(GL_QUADS)
...
glEnd()
glDisable(GL_BLEND)

I'm also experimenting now with gluLookAt instead of my previous Camera 
class, which relied on glTranslatef and glRotatef, because gluLookAt 
offers a way to explicitly track the motion of a particular character. 
But that messes up the sprites' billboarding... Gah.


Kris


Re: [pygame] [OpenGL] Text, Transparency and Lists

2006-09-16 Thread Richard Jones
On Sunday 17 September 2006 11:31, Kris Schnee wrote:
> I've put the latest code at:
> http://kschnee.xepher.net/code/scurvy.py

Looks like you've enabled blending without specifying a blend function. You'll 
want something like:

   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

This indicates to use the texture's alpha channel for the texture imagea and 
the opposite (one minus) for the ground image.


 Richard