iOS Metal线宽 [英] iOS Metal line width
问题描述
我想设置我在Metal中绘制的线条的宽度.我可以使用point_size设置点的大小,如下所示:
I would like to set the width of a line that I'm drawing in Metal. I can set the size of a point with point_size as explained here:
但是,我不确定它如何与线一起工作.
But, I'm not sure how it works with lines.
推荐答案
简短的答案是,无法像在Metal中那样以相同的方式控制线宽.即使在OpenGL图形API中,现在也已不建议执行此功能(该功能以前以gllinewidth功能存在).
Short answer would be there is no way to control line width in the same way as a point size in Metal. Even in OpenGL graphics API, the function to do this (which used to exist as gllinewidth function) is now deprecated.
一个选择是将线条绘制为具有两个三角形的四边形(一个框).这样您就可以控制线条的宽度.
An option would be to draw the line as a quad (a box), with two triangles. This would let you control the width of the line.
如果出于某些特定原因想要坚持使用行原语本身,则已经在StackOverflow上提出了等效的OpenGL问题,如此处.可以将着色器简单地转换为Metal着色API.
If you want to stick to the line primitive itself, for some particular reason, the equivalent OpenGL question has been asked on StackOverflow already as seen here. The shader can be simple translated to Metal shading API.
这篇关于iOS Metal线宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!