简体   繁体   中英

Blending Function on OpenGL ES 1.0 (Android)

I'm using OpenGL ES 1.0 for Android. I've a shape composed by 2 triangles (quad) like a play card. The texture used for this play card have smooth corners (transparent)

When i draw the shape... enable blend function in this way:

    gl.glEnable(GL10.GL_BLEND);
    gl.glBlendFunc(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);

If i draw only one card all work fine!!!

But, when i draw many cards... and add some rotations, i can see the corners of the shape:

在此输入图像描述

How can i have transparent effects on all frames? There is a way to replace the blending on all frame?

You would probably be better served by alpha testing glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.1f); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.1f); than by blending, because when using blending you must sort your to draw them from front to back.

It looks like you're drawing the top card first, and then drawing the cards underneath it, while with blending you must draw the bottom card first for it to blend properly.

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