Jump to content
  • Advertisement
Sign in to follow this  

Problem with Alpha channel

This topic is 4414 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

Hi, I seem to be having some trouble with transparency. Weather if its 0 255 or even 100 its is always solid. I am using it from within an ortho projection, and it is always the same solid color as a said above. Here is the code. Also off topic, how would you make a 2D circle, no a sphere. Note this code is kinda implimented fast, as it should not be a square but a cylinder, so ignore the bad coding, as some of it was just copied and pasted.
glColor4ub(20,20,20,100);
				///auxSolidSphere(Size);
				//glColor4f(0.5f,0.5f,0.5f,1.0f);

					int TileWidth = Size;
					int TileHeight = Size;
					glBegin(GL_QUADS);
						//glColor3ub(255, 255, 255);
							//glTexCoord2f(0.0, 0.0); 
							glVertex3f((TileWidth / 2), (TileHeight / 2),0.0f);
						//glColor3ub(255, 255, 255);
							//glTexCoord2f(1.0, 0.0); 
							glVertex3f((TileWidth / 2), -(TileHeight / 2),0.0f);
						//glColor3ub(155, 155, 155);
							//glTexCoord2f(1.0, 1.0); 
							glVertex3f( -(TileWidth / 2), -(TileHeight / 2),0.0f);
						//glColor3ub(155, 155, 155);
							//glTexCoord2f(0.0, 1.0); 
							glVertex3f( -(TileWidth / 2), (TileHeight / 2),0.0f);
					glEnd();	

Share this post


Link to post
Share on other sites
Advertisement
Did you enable blending? ( glEnable(GL_BLEND); ) Are the vertex colours actually affecting the colour other than the transparency? (ie. 20,20,20,100 should be a very dark grey).

Share this post


Link to post
Share on other sites
I figured out the problem, however I am not sure how I would go about fixing it. With ortho the first item drawn is always on top (or seems to be for me, even with a z axis of a greater number). However for alpha to work the transparent item has to be drawn later/after the one before it. However if this is done the background makes the item I want to disappear. So it seems I can not achieve the effect of seing the background.

1)Background has to be drawn first, then the transparent item?
2)In ortho first drawn is always on top?

Share this post


Link to post
Share on other sites
Ok, well I tried to render my map, as the very first thing put on the screen then my sprites after. However it seems as though my sprites are almost totally see through, and its gun that over laps the sprite makes it appears completely see thrrough, like an alpha of 0) although I never assigned as alpha channel to them. What could be causing this. My map is a z -999 and my sprites and gun are at 0. PS: This is with ortho again.

EDIT: I am not using any alpha channel for this.

[Edited by - starfleetrp on April 20, 2006 11:18:57 AM]

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!