本文介绍了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() 不会改变行的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 09:50