1
\$\begingroup\$

I am new on OpenGl and what I want to achieve is to give a texture the alpha from 1.0 to 0.0

I have been searching and only found "how to load alpha in images" but I cant find how to apply alpha to an object

I has been tried with:

    gl.glEnable(GL10.GL_ALPHA_TEST);
    alpha += 0.002f;
    if(alpha > 1) alpha = 1f;
    gl.glAlphaFunc(GL10.GL_EQUAL, alpha);

But it doesn't work.

How I can give alpha value (to make the effect of fade) to an object/texture?

\$\endgroup\$
  • \$\begingroup\$ I removed your code, as this doesn't really have to do with your code. The question is how to make an object transparent, not how to add it to your code. I'm not sure how to do it myself, but this is most likely going to be a shader effect. \$\endgroup\$ – MichaelHouse Nov 27 '14 at 15:16
  • \$\begingroup\$ It cant be done in OpenGL ES 1.0? \$\endgroup\$ – D4rWiNS Nov 27 '14 at 15:40
0
\$\begingroup\$

I made it!

That is the code

gl.glEnable(GL10.GL_BLEND);
gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
gl.glColor4f(1f, 1f, 1f,alpha);
alpha -= 0.002f;
if(alpha < 0) alpha = 0f;
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.