//init
glBlendFunc(GL_SRC_ALPHA,GL_ONE);
glEnable(GL_BLEND);
//frame
glColor4f(0,0,0,0);
glLoadIdentity();
glBindTexture( GL_TEXTURE_2D, m_Textures[2].GetTexID() );
glTranslatef(60,90,120);
glColor3f(0.5f, 0.8f, 0.3f);
glBegin(GL_QUADS);
m_Textures[2].DrawSprite(circle[i].CircleScale);
glEnd();
I tried to make the texture totally transparent: glColor4f(0,0,0,0);
It doesn''t work... All my textures seems to always be blending between each other, but their transparency level doesn''t change at all when I modify glColor4f
What should I do?
Thanks
Transparency
Hey, I''m using 2d ortho mode and I want to change the transparency value of a texture.
Try the following:
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
This is the generic alpha blending equation and will serve you well in most cases.

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
This is the generic alpha blending equation and will serve you well in most cases.

"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
Do your textures have an alpha channel? If they do, are you creating your textures with the GL_RGBA flag?
If you want color-based blending, try:
glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);

If you want color-based blending, try:
glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);

"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
I''m loading TGA images with an alpha channel ( GL_RGBA )
All I want to do is make some of my texture transparent and be able to control the transparency level of my textures.
All I want to do is make some of my texture transparent and be able to control the transparency level of my textures.
quote:
Original post by Hedos
I''m loading TGA images with an alpha channel ( GL_RGBA )
All I want to do is make some of my texture transparent and be able to control the transparency level of my textures.
Tell you what - that won''t happen till you make it happen. Your options are:
1) if you don''t know what''s going on, refer to a tutorial or post some actual relevant code
2) if you''re too lazy to look it up in some tutorial, post some actual relevant code
3) if you don''t want to post code, don''t ask the question because no one can answer it unless you give out some nice details
4) if you''re planning on posting code, post only the key portions because no one enjoys reading others'' code in order to locate mistakes in it
There are a billion things people could suggest you do, but that wouldn''t be very rational, would it?
You could, though, start by checking if the alpha channel contains any relevant data and if you''re creating the texture correctly. Also, the statement glColor4f(0, 0, 0, 0) is redundant and glColor3f(0.5, 0.8, 0.3) actually translates to glColor4f(0.5, 0.8, 0.3, 1), which could explain why your blending isn''t working.
I''m sorry, but these kind of questions are awfully noobish and usually not worth a thread - generally they can be solved by changing one little detail in your code (remember - YOU (should) know your code the best, so forcing others to delve into it isn''t something you should do unless you''re sure you don''t know the answer) - this can be accomplished by revising the code several times (that is, reading through it with thought and changing things as neccessary).
I think we''ve seen you around on these forums for quite some time now so you should know these things...
Sorry to have possibly sounded a little harsh, but it requires a mental reset to enter somebody else''s mindset (code) and start looking for a typo or something similar...

"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
are you passing the correct pixel size when you create the texture?
[size="2"]I like the Walrus best.
Thanks for your replies
owl: Yes I''m pretty sure I''m passing the correct pixel size
Crispy: Thanks for your comments and suggestions.
Actually, I did researchs ( on google, on gamedev forums ) before posting my question.
I learned how to do transparency by using tutorials, it worked correctly, but it didn''t allow me to change the level of transparency...
I also have been revising my code and did not see any errors.
It''s why I decided to post this question.
(as for the code posting, I have nothing against showing my code... And I showed the important parts of my code in my first post)
Well.. you were right for the glColor3f.
I did not understand how glColor4f truly worked and I didn''t realised glColor3f was interfering with my transparency.
Now, everything works fine.
Thanks a lot
owl: Yes I''m pretty sure I''m passing the correct pixel size
Crispy: Thanks for your comments and suggestions.
Actually, I did researchs ( on google, on gamedev forums ) before posting my question.
I learned how to do transparency by using tutorials, it worked correctly, but it didn''t allow me to change the level of transparency...
I also have been revising my code and did not see any errors.
It''s why I decided to post this question.
(as for the code posting, I have nothing against showing my code... And I showed the important parts of my code in my first post)
Well.. you were right for the glColor3f.
I did not understand how glColor4f truly worked and I didn''t realised glColor3f was interfering with my transparency.
Now, everything works fine.
Thanks a lot

This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement