# Controlling model transparency [SOLVED]

## Recommended Posts

I was wondering if it is possible to control textured model transparency accordingly:
void drawStuff() {
setTransparency(alpha); // set transparency for model.
glDrawElements(...);    // draw model with transparency
}
/* ... */

void setTransparency(float alpha) {
alpha=clamp(alpha,0,1);
/*
*  ?
*/
}


I'm looking for a solution which is something like this. Is this possible? As I was researching this I noticed glTexEnv was mentioned few times, but I don't quite get it :| EDIT: Adding following code solved the case:
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(1,1,1,alpha);

my problem was that I had the "glEnable(GL_COLOR_MATERIAL);" missing. I think this is because I had lighting enabled. [Edited by - rxa on February 23, 2010 11:20:21 PM]

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
627701
• Total Posts
2978701

• 21
• 14
• 12
• 10
• 12