Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 N1ghtDr34m3r   Members   -  Reputation: 152

Like
0Likes
Like

Posted 04 November 2012 - 03:23 PM

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:

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

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

Sponsor:

#2 karwosts   Members   -  Reputation: 840

Like
2Likes
Like

Posted 05 November 2012 - 01:48 AM

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:


float alphaMin = 0.1;
if(color.a < alphaMin) { discard; }

This achieves the same effect as alpha testing.
My Projects:
Portfolio Map for Android - Free Visual Portfolio Tracker
Electron Flux for Android - Free Puzzle/Logic Game

#3 N1ghtDr34m3r   Members   -  Reputation: 152

Like
0Likes
Like

Posted 05 November 2012 - 02:06 PM

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()"
^^




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS