开发者

Broken line at joins in opengl on iphone

I am using cocos2d to draw custom shapes for a game. I have an array of polygon points that I use to plot the border of a polygon using the below opengl code.

glEnable(GL_LINE_SMOOTH);
glB开发者_JAVA百科lendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glLineWidth(4);
glVertexPointer(2, GL_FLOAT, 0, polyVertices);
glDrawArrays(GL_LINE_LOOP, 0, polyVertexCount);

However, I get this result (LINK) on simulator.

It seems that the problem is where the line segments are supposed to join. How do I solve this? What are the options to create different join types in opengl es? Is there any drawing library I could use?


Line width in OpenGL does not allow for the miter between contiguous lines to join with one another. So if you have a line that goes up which is connected to a line that goes left, there will be a very obvious discontinuity if the line width is > 1.

If you're serious about line drawing with line width, and you need the miters to join, then you need to not use OpenGL's line drawing. You need to create a polygonal mesh that represents what you're trying to draw and do the miter computations yourself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜