绘制圆轮廓的百分比

编程入门 行业动态 更新时间:2024-10-10 11:20:25
本文介绍了绘制圆轮廓的百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在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()函数定义线宽。

更多推荐

绘制圆轮廓的百分比

本文发布于:2023-07-19 13:38:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1157050.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:百分比   轮廓

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!