绘制圆轮廓的百分比 [英] Draw percentage of circle outline

查看:188
本文介绍了绘制圆轮廓的百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

这篇关于绘制圆轮廓的百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆