Sprites... to mask or not to mask
Do i have to mask the sprites for the blending not to make my sprites really bright..., or is there an alternative way?
Languages: C/C++ C# JavaAPIs: Win32 OpenGL DirectXWeb: javascript Perl JSP PHP-MySQL Oracle Database Programming</span><a href='http://www.ethereal-studios.com'>http://www.ethereal-studios.com</a></a>
try glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA).I It sounds like youre using GL_SRC_ALPHA, GL_ONE to blend your sprites onscreen
Kinda an old topic, but I finally figured out something that works so i don''t have to use a mask. All my sprites have a black background, and the main OGL seen in the 2D world is black. So I used this blending function glBlendFunc(GL_ONE_MINUS_DST_COLOR,GL_ZERO|GL_ONE_MINUS_SRC_COLOR);
It seems to work so far.
It seems to work so far.

Languages: C/C++ C# JavaAPIs: Win32 OpenGL DirectXWeb: javascript Perl JSP PHP-MySQL Oracle Database Programming</span><a href='http://www.ethereal-studios.com'>http://www.ethereal-studios.com</a></a>
You could also give your sprites and alpha channel and use an alpha_test to draw them to your screen.
<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>
hmm... how would i go about doing that... is there a demo anywhere?
Languages: C/C++ C# JavaAPIs: Win32 OpenGL DirectXWeb: javascript Perl JSP PHP-MySQL Oracle Database Programming</span><a href='http://www.ethereal-studios.com'>http://www.ethereal-studios.com</a></a>
probabely at NeHe''s somewhere. But it''s real easy. Load you sprite in a painting program, select your sprite outline and paste it to the alpha channel (this is how it works in Paint Shop Pro). Save it. It''s now a 32 bit image (you might want to use the .tga format from now on).
in your program, when before you draw your sprite, set the alpha test to be greater than 0.99f. This means that only pixels with an alpha of more than 0.99f are drawn to the screen (and Z buffer). Your sprite has alpha 1 and the background of the sprite has alpha 0 remember?
Enable the alpha test and draw your sprite. Only the sprite itself gets draw now and depth testing is still fully functional.
You''re done. Happy coding!
- An eye for an eye will make the world go blind -
in your program, when before you draw your sprite, set the alpha test to be greater than 0.99f. This means that only pixels with an alpha of more than 0.99f are drawn to the screen (and Z buffer). Your sprite has alpha 1 and the background of the sprite has alpha 0 remember?
Enable the alpha test and draw your sprite. Only the sprite itself gets draw now and depth testing is still fully functional.
You''re done. Happy coding!
- An eye for an eye will make the world go blind -
<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>
Thanks
I know how to add a alpha channel to a bmp, so maybe i can do that...?

Languages: C/C++ C# JavaAPIs: Win32 OpenGL DirectXWeb: javascript Perl JSP PHP-MySQL Oracle Database Programming</span><a href='http://www.ethereal-studios.com'>http://www.ethereal-studios.com</a></a>
If I remebre correctly, BMP doesn''t support 32-bit images. Only 24 bit. If you add an alpha channel to your BMP in a painting program it will work, but when you click "save" it''s gone. If you really want to use BMP, make a separate (greyscale) file for the alpha channel and manually load it into the alpha channel of the texture before building it.
But I reccommend .tga. That way you can also dump the GLaux library.
- An eye for an eye will make the world go blind -
But I reccommend .tga. That way you can also dump the GLaux library.
- An eye for an eye will make the world go blind -
<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>
yea, i never used the glaux, but i wrote up a tga file loader... whatever, and i''m using tga for the sprites. thanks for the advice

Languages: C/C++ C# JavaAPIs: Win32 OpenGL DirectXWeb: javascript Perl JSP PHP-MySQL Oracle Database Programming</span><a href='http://www.ethereal-studios.com'>http://www.ethereal-studios.com</a></a>
Welcome :-)
If you need more, contact me. I''ll be around.
- An eye for an eye will make the world go blind -
If you need more, contact me. I''ll be around.
- An eye for an eye will make the world go blind -
<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement