opengl glLineWidth()不会更改行的大小 [英] opengl glLineWidth() doesn't change size of lines

查看:905
本文介绍了opengl glLineWidth()不会更改行的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了此函数,在其中设置了绘制矩形的线宽,但是在调用它时,线宽根本没有改变.我如何正确使用glLineWidth?

I wrote this function, where I set up line width to draw a rectangle, but when calling it, the line width doesn't change at all. How can i use glLineWidth correctly?

void drawRect(Rectangle &rect)
{
      double x1 = rect.min.x;
      double y1 = rect.min.y;
      double x2 = rect.max.x;
      double y2 = rect.max.y;

      glLineWidth(3.0f);
      glBegin(GL_LINE_LOOP);
            glVertex2d(x1, y1);
            glVertex2d(x2, y1);
            glVertex2d(x2, y2);
            glVertex2d(x1, y2);
      glEnd();

}  

推荐答案

支持宽线渲染不需要OpenGL实现.

OpenGL implementations are not required to support rendering of wide lines.

您可以使用以下方法查询支持的线宽范围:

You can query the range of supported line widths with:

GLfloat lineWidthRange[2] = {0.0f, 0.0f};
glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, lineWidthRange);
// Maximum supported line width is in lineWidthRange[1].

两个限制所要求的最小值均为1.0,这意味着不需要支持大于1.0的线宽.另外,绘制粗线也是一项不推荐使用的功能,如果您使用较新的(核心配置文件)OpenGL版本,将不再支持此功能.

The required minimum for both limits is 1.0, meaning that support for line widths larger than 1.0 is not required. Also, drawing wide lines is a deprecated feature, and will not be supported anymore if you move to a newer (core profile) version of OpenGL.

绘制宽线的另一种方法是渲染细多边形.

An alternative to drawing wide lines is to render thin polygons instead.

这篇关于opengl glLineWidth()不会更改行的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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