Jump to content
  • Advertisement
Sign in to follow this  
Fire Lancer

OpenGL Alpha Blended textures

This topic is 3350 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

I've been trying to work out how to do alpha blending with 32bit GL_RGBA textures, but haven't had much luck. Id Like it to work (where d is the render target, s is the texture, and c is the colour set by glColor) with the following equation (Hopefully this is right lol). d.rgb = (s.rgb * c.rgb)*s.a + d.rgb*(1 - s.a) In Direct3D I could do it with an A8R8G8B8 texture by doing the following: SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); And the following render states: D3DRS_ALPHABLENDENABLE, TRUE SourceBlend = D3DBLEND_SRCALPHA DestBlend = D3DBLEND_INVSRCALPHA However having searched around all day Ive not managed to do the same thing in openGL :(

Share this post


Link to post
Share on other sites
Advertisement
The default texture environment setup (glTexEnv function) uses GL_MODULATE, so you don't need to change that.

Then, just enable blending glEnable(GL_BLEND); and set the blending function with glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) and you should get the same behaviour as D3D.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!