I’m trying to draw semi-transparent primitives (lines, circles) in OpenGL ES using Cocos2d but can’t avoid the visible overlap regions. Does anyone know how to solve this?

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is a problem you usually come across pretty often, even in 3D.
I’m not too familiar with Cocos2D, but one way to solve this in generic OpenGL is to fill the framebuffer with your desired alpha channel, switch the blending mode to
glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA)and draw the rectangles. The idea behind this is that you draw a rectangle with the desired transparency which is taken from the framebuffer, but in the progress mask the area you’ve drawn to so that your subsequent rectangles will be masked there.Another approach is to render the whole thing to a texture or assemble the shape using polygons that don’t overlap.
I’m not sure whether Cocos2D supports any of these…