Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opengl glLineWidth() doesn't change size of lines

Tags:

opengl

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();

}  
like image 456
daydayup Avatar asked Jan 19 '16 01:01

daydayup


1 Answers

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].

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.

like image 153
Reto Koradi Avatar answered Sep 20 '22 06:09

Reto Koradi