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 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With