Hello,

I've been working on moving from Canvas over to OpenGL using
GLSurfaceView and have hit a bit of a roadblock in trying to change
the alpha of a texture at runtime.  I can display the texture with
transparency just fine but changing the RGBA via glColor isn't doing
anything at all.  All I'm trying to do is fade in and out some
textures by changing the alpha value and I know it's possible because
I've seen it done before.  I get the feeling like I'm just missing one
line of code to fix this.

Here is the actual draw method for the object

public void draw(GL10 gl)
{
                gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureName);

                gl.glColor4f(1f, 1f, 1f, 0.5f); // No matter what I make these
values it doesn't change anything

                ((GL11) gl).glTexParameterfv(GL10.GL_TEXTURE_2D,
GL11Ext.GL_TEXTURE_CROP_RECT_OES, textureGrid, 0);
                ((GL11Ext) gl).glDrawTexfOES(x, y, z, width, height);
 }

and here is some of the initialization code, it's pretty much just
copied straight from the SpriteMethodTest example

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_FASTEST);

        gl.glClearColor(0.5f, 0.5f, 0.5f, 1);
        gl.glShadeModel(GL10.GL_FLAT);
        gl.glDisable(GL10.GL_DEPTH_TEST);
        gl.glEnable(GL10.GL_TEXTURE_2D);

        gl.glDisable(GL10.GL_DITHER);
        gl.glDisable(GL10.GL_LIGHTING);

        gl.glClear(GL10.GL_COLOR_BUFFER_BIT |
GL10.GL_DEPTH_BUFFER_BIT);

        // Load all the Textures
    }

    public void onSurfaceChanged(GL10 gl, int w, int h) {
        gl.glViewport(0, 0, w, h);

        gl.glMatrixMode(GL10.GL_PROJECTION);
        gl.glLoadIdentity();
        gl.glOrthof(0.0f, w, 0.0f, h, 0.0f, 1.0f);

        gl.glShadeModel(GL10.GL_FLAT);
        gl.glEnable(GL10.GL_BLEND);
        gl.glBlendFunc(GL10.GL_SRC_ALPHA,
GL10.GL_ONE_MINUS_SRC_ALPHA);
        gl.glColor4f(1f, 1f, 1f, 1f);
        gl.glClearColor(1f, 1f, 1f, 1f);
        gl.glEnable(GL10.GL_TEXTURE_2D);
    }

Thanks in advance!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to