• Advertisement
Sign in to follow this  

glAlphaFunc in gl20 ? or How do I enable alpha in gl20 ?

This topic is 1902 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys.

I'm currently coding a little game with the libGdx library and I wanted to have a slight fade in/fade out effect if the screen changes (e.g. from MainMenu into the game).
After some time, I've got the idea, that I draw a black filled rectangle over the whole screen with an increasing alpha value. At the point where the alpha value is 0.0f (so, the whole screen is black) I change the screen to my game, where at this point my alpha value is getting bigger (so it will be transparent more and more).

So I implemented something like this:

[CODE]
// init
Gdx.gl.glEnable( GL10.GL_ALPHA_TEST );
// [...]
// render
Gdx.gl10.glAlphaFunc( GL10.GL_GREATER, 0 );
// render my quad
[/CODE]

While having my project setting up with LwjglApplicationConfig.useGL20 = false; it will work very well.
But enabling gl20, it won't start, saying that there is a problem with GL10.GL_ALPHA_TEST
So I searched if gl20 have something like that... but now it's 30 minutes later and I don't have any solution.

Could you help?
What I have to enable in gl20 ( and setting up) to use alpha like in gl10 ?

Greets,
N1ghtDr34m3r

Share this post


Link to post
Share on other sites
Advertisement
The built in alphaFunc is gone in GL20 because you're expected to replicate it in shader with the 'discard' keyword.

Basically at some point in your fragment shader you'll have:

[CODE]

float alphaMin = 0.1;
if(color.a < alphaMin) { discard; }
[/CODE]

This achieves the same effect as alpha testing.

Share this post


Link to post
Share on other sites
Oh... I'm so a badass boy, I don't use gl20 with a shader. xD
Thank you very much. Now I know what I will google later. ;-)

"Thread.join()"
^^

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement