在OpenGL中,如何绘制圈子的大纲的给定百分比?如何控制轮廓的粗细?
In OpenGL, how can I draw a given percentage of the outline of a circle? And how can I control the thickness of that outline?
示例:如果百分比是100,则应绘制一个完整圆的轮廓。如果百分比是50,应该绘制半个圆的轮廓。
Example: If the percentage is 100, then the outline of a full circle should be drawn. If the percentage is 50, the outline of half a circle should be drawn.
我试过下面的,但问题是它完成了lineloop,领先到连接圆轮廓的起点和终点的线。此外,它不接缝,让我改变大纲的厚度。
I've tried the following, but the problem there is that it completes the lineloop, leading to a line connecting the startpoint and endpoint of the circle outline. Additionally, it does not seam to let me change the thickness of the outline.
glBegin(GL_LINE_LOOP); for (int i=0; i < (360/10*percent/10); i++) { float degInRad = i*DEG2RAD; glVertex2f(a+cos(degInRad)*r,b+sin(degInRad)*r); } glEnd();我试图让我的GL_POINTS的圈子,但我想知道是否有更好的方法?
I am tempted to just make my circle up of GL_POINTS, but I was wondering if there is a better way?
推荐答案使用 GL_LINE_STRIP替换 GL_LINE_LOOP ,这样最后和第一个顶点不连接。使用 glLineWidth()函数定义线宽。
更多推荐
绘制圆轮廓的百分比
发布评论