I wish to draw an image to the screen, but I also want to adjusts its alpha value’s with a slider control.
I am using OpenIL so the Texture is loaded and passed to Opengl without a pointer to the textures pixels.
Is the best and most efficient way to do this:
use glGetTeximage to get a pointer to the pixels of the texture.
then manually manipulate the pixels alpha value in a loop.
And finally use glTextSubImage to place the altered texture over the top of the old one?
does this sound right?
paddy
January 27, 2001, 5:16pm
2
Why not change the material properties ?
glMaterialfv(GL_FRONT_AND_BACK,…
There you can directly change the transparency of your polygon’s material with having to reload the texture
I will try this paddy.
and dont wink at me yer cheeky monkey:-)
paddy
January 27, 2001, 6:48pm
4
Finally someone with humor on these boards
Ooops sorry …
Hey paddy do a search on “The Ironduke” on these forums.
We use to have a laugh
Paddy I dont think material will make the texture transparent thus showing other objects beneath it?
or will it?
please explain.
paddy
January 27, 2001, 10:35pm
7
Yes it will !
First set the blending mode :
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
Then set the material properties :
GLfloat glparms[4];
glparms[0]=your_red;
glparms[1]=your_green;
glparms[2]=your_blue;
glparms[3]=your_alpha;
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, glparms);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, glparms);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, glparms);
You can of course use different colors for ambient, diffuse and specular !
If you use an alpha value smaller than 1.0, the material will be rendered with transparency.
If you want the object to ‘glow’ in the dark :
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, glparms);
What you have to do is to render the polygons from farthest to nearest for correct transparency management.
ENJOY !
PS : Damn english, have to edit the post again (i’m French )
[This message has been edited by paddy (edited 01-28-2001).]
A french man called paddy?
Maybe patrice? Cancelled french in school last year… But the girls are gerat
paddy
January 28, 2001, 3:12pm
10
My real name is Patrick … but i love Ireland and Whiskey !
And yes, french girls are great… other things are cool in France too, it’d worth a visit
I’ve been three times to france. Next holidays I’ll make a trip there with my sister again. Will be great fun. Though I think that french people like their joints better than the girls…
Thanx paddy it worked although I had to remove the line.
glTexEnvi…etc as this reversed the colours of the original texture when alpha was = 1 in the material colour.
do you know why?