Jump to content
  • Advertisement
Sign in to follow this  

Blending&textures problem.

This topic is 4088 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'm creating a 2D game and I want to use some transparent sprites, but the blending doesn't work for me the way I want it to work. I've made a 2x2 texture to test it. CODE! texlist[1]:=255; //1 R texlist[2]:=0; /// 1 G texlist[3]:=0; /// 1 B texlist[4]:=255; //1 A texlist[5]:=0; /// 2 R texlist[6]:=255; //2 G texlist[7]:=0; /// 2 B texlist[8]:=255; //2 A texlist[9]:=0; /// 3 R texlist[10]:=0; // 3 G texlist[11]:=255;//3 B texlist[12]:=255;//3 A texlist[13]:=255;//4 R texlist[14]:=0; // 4 G texlist[15]:=255;//4 B texlist[16]:=0; // 4 A gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, 2,2, GL_RGBA, GL_BYTE, @texlist); END OF CODE! The output was 1 on this pic: http://img222.imageshack.us/img222/2118/rgbajm9.jpg But I want it to work as shown on second pic - I want the entire transparent pixel not to be visible. I've been trying almost everything. The key is probably the glAlphaFunc or glBlendFunc glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.5); // modyfying this value changes the radius of that transparent circle. glBlendFunc(GL_ONE,GL_ONE); glEnable(GL_BLEND); additional pic http://img233.imageshack.us/img233/8564/50869792ov3.jpg

Share this post

Link to post
Share on other sites
glBlendFunc... try glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
There are many more possible combinations for this, but the one I just gave works well for standard transparency.

Share this post

Link to post
Share on other sites
It didn't change anything. I have later figured that blending doesn't matter here anyway.

But well I have changed glAlphaFunc(GL_GREATER, 0.8); to 0.8 as it has given best results and loaded some sprites. Take a look.


My looks like pasted in paint :|. How do I make it so that edges blends or w/e is happening there

Share this post

Link to post
Share on other sites
I got some better results using

//glAlphaFunc(GL_GREATER, 0.1);
I didn't know that turning alpha test off may improve this :P


But now anyone knows how to get rid of those lines?

Edit. Where can I get newer OpenGL libraries for Delphi?
coz ... [Error] main.pas(114): E2003 Undeclared identifier: 'GL_MIRRORED_REPEAT'

[Edited by - Enderdil on September 30, 2007 7:35:20 AM]

Share this post

Link to post
Share on other sites
Those are most likely edge artifacts from the texture/sprite itself. Have you checked the sprite images themselves to assert that the edges of them are clean? If they are, then its some GL border issue or such, and I'm drawing a blank.

Share this post

Link to post
Share on other sites
Sprites are 100% fine, but OpenGL tries to repeat those textures probably. I've managed to disable repeating by
but then other textures looks worse (eg. ground sprites)
I thought that solution for this would be adding a property for each texture telling to CLAMP or to REPEAT but what if my sprite looks like that!
Notice the lines at the top and bottom on the repeating one.

I've been thinking on creating textures using:
then drawing everything I want
and then SMOTHING THE ENTIRE SCREEN just like textures are being smothed when using
Is there any easy way (glEnable ?) or would I have to copy the screen as a testure and draw it on one quad on the screen ?

[Edited by - Enderdil on September 30, 2007 4:54:17 PM]

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!