views:

505

answers:

2

I'm trying to set the transparency of a texture on a quad in opengl, playing with the blend functions didn't help neither did anything on google. Any suggestions?

A: 

I had a similar problem, with one piece of code that worked correctly and another that didn't. After a lot of logging and debugging, I found that the difference was one line of code.

In the code that had working alpha, I was calling the following before setting my renderer.

    setEGLConfigChooser(false)

If that doesn't help, here are a couple of other pointers...

Make sure that you've enabled blending before you load the texture.

For example:

    // Enable blending using premultiplied alpha.
    gl.glEnable(GL10.GL_BLEND);
    gl.glBlendFunc(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);

...and make sure that the bitmap that you're using to generate the texture actually has an alpha component.

Rod Hyde
+1  A: 

I was able to fix my problem listed using a different method. I first set

gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, /*GL10.GL_REPLACE*/ GL10.GL_MODULATE);

Then was able to set the alpha of a texture using

gl.glColor4f

Sudden