Problem with Alpha channel

Started by
3 comments, last by starfleetrp 18 years ago
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();	
Advertisement
Enabled blending and set proper blending function? GL_SRC_ALPHA/GL_ONE_MINUS_SCR_ALPHA is probably the blending function you want.
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).
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?
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]

This topic is closed to new replies.

Advertisement