简体   繁体   中英

Android, OpenGL ES 1.0, Alpha

I'm new with OpenGLES and I was trying to draw a rectangle with alpha but alpha not being effected on screen. Please help me to figure out where I'm out of the line.

GLES10.glEnableClientState(GL10.GL_VERTEX_ARRAY);
GLES10.glClear(GL10.GL_COLOR_BUFFER_BIT);
GLES10.glColor4f(0.5f, 0.5f, 0.5f, 0.1f);  <-- NOT Working , please help 0.1 alpha not taken   
GLES10.glPushMatrix();GLES10.glEnableClientState(GL10.GL_VERTEX_ARRAY);
GLES10.glVertexPointer(
        3,
        GL10.GL_FLOAT,
        0,
        RendererImpl.makeFloatBuffer(new float[] { -160.0f, -100.0f,
                0.0f, 160.0f, -100.0f, 0.0f, 160.0f, 100.0f, 0.0f,
                    -160.0f, 100.0f, 0.0f }));
GLES10.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0, 4);
GLES10.glDisableClientState(GL10.GL_VERTEX_ARRAY);
GLES10.glPopMatrix();
GLES10.glFlush();

If you want your objects that you draw to be transparent, then you first must enable blending.

Draw your background first, then set these options:

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

Then try to draw your transparent object as you have done above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM