Jump to content
  • Advertisement
Sign in to follow this  
Uthman

OpenGL mask blended images

This topic is 4950 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 am trying to draw some smoke billboards for the tires in my car game. The billboarding system works perfect, as I have verified this by drawing polygons w/o blending. So next up, I wanted to have the billboarded all polygons nicely blended together. I've tried every combination of Opengl's blending:
/* BlendingFactorDest */
#define GL_ZERO                           0
#define GL_ONE                            1
#define GL_SRC_COLOR                      0x0300
#define GL_ONE_MINUS_SRC_COLOR            0x0301
#define GL_SRC_ALPHA                      0x0302
#define GL_ONE_MINUS_SRC_ALPHA            0x0303
#define GL_DST_ALPHA                      0x0304
#define GL_ONE_MINUS_DST_ALPHA            0x0305
but in the end, when the polygons were being drawn, they would cover each other instead of properly blending. I know how to mask polygons, but is there any way to set it up so that I can mask And blend polygons at the same time?

Share this post


Link to post
Share on other sites
Advertisement
this is what i use

glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);

glBlendFunc(GL_DST_COLOR,GL_ONE_MINUS_SRC_ALPHA);
glColor4f(t,t,t,t);
glBegin(GL_QUADS);
// draw mask here
glEnd();

glBlendFunc(GL_SRC_ALPHA,GL_ONE);
glColor4f(1.0f,1.0f,1.0f,t);
glBegin(GL_QUADS);
// draw image here
glEnd();

glColor4f(1.0f,1.0f,1.0f,1.0f);
glEnable(GL_DEPTH_TEST);
glDisable(GL_BLEND);



if this isnt what you are looking for i could find another way if you could be more specific on how you would like the blending to work

edit: t = alpha

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!