iPhone 上的 opengl 连接处断线
我正在使用 cocos2d 为游戏绘制自定义形状。我有一个多边形点数组,我用它来使用下面的 opengl 代码绘制多边形的边界。
glEnable(GL_LINE_SMOOTH);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glLineWidth(4);
glVertexPointer(2, GL_FLOAT, 0, polyVertices);
glDrawArrays(GL_LINE_LOOP, 0, polyVertexCount);
但是,我得到了这个结果(LINK) 在模拟器上。
问题似乎出在线段应该连接的地方。我该如何解决这个问题?在 opengl es 中创建不同连接类型的选项有哪些?有没有我可以使用的绘图库?
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);
glBlendFunc(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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
OpenGL 中的线宽不允许相邻线之间的斜接相互连接。因此,如果有一条向上的线与向左的线相连,如果线宽 > ,将会出现非常明显的不连续性。 1.
如果你认真对待线宽的画线,并且需要斜角连接,那么你不需要使用OpenGL的画线。您需要创建一个多边形网格来表示您要绘制的内容并自行进行斜接计算。
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.