Skip to main content
GameDev.net gamedev.net
๐Ÿ”’ Locked

Alpha color doesn't work

Started by Ator Dec 11, 2005 at 12:29 PM 4 replies 500+ views
Original Post
Ator
Ator
How do I get 50% transparent polygons? This is my code: (I have overlapped polygons, generated as below) glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE); glColor4f(1.0, 0.0, 0.0, 0.5); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glBegin(GL_POLYGON); glVertex2f(0.0, 0.0); glVertex2f(0.0, 1.0); glVertex2f(1.0, 0.0); glEnd(); glDisable(GL_BLEND); Kind Regards Andreas
nts
nts
try
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Also make sure you sort and render your polygons from back to front.

HTH
Ator
Ator
Quote:
Original post by nts
try
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Also make sure you sort and render your polygons from back to front.

HTH


What do you mean by sort? Sorting regarding what?

/ Andreas
rapunzel
rapunzel
sort them regarding to their depth. means you should draw the polygon that is most far away first, then the one that is second most far away and so on ...
pauls_1979
pauls_1979
You will need to sort you primitives in order of depth so that those fursthest from the screen are rendered first. Otherwise when the blend operations are performed chances are the z-buffer will contain incorrect values.
Ator
Ator
Quote:
Original post by rapunzel
sort them regarding to their depth. means you should draw the polygon that is most far away first, then the one that is second most far away and so on ...


My code above doesn't render 3D-polygons.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.