I am aware that drivers are not required to support variable line widths, the manner of querying driver support is shown with this answer:
GLfloat lineWidthRange[2] = {0.0f, 0.0f};
glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, lineWidthRange);
std::cout << "line width range: " << lineWidthRange[0] << ", " << lineWidthRange[1] << std::endl;
Querying the current line width:
GLfloat currLineWidth[1] = {0.0f};
glGetFloatv(GL_LINE_WIDTH, currLineWidth);
std::cout << "line width before: " << currLineWidth[0] << std::endl;
So right now, it should and does report 1
for the current line width. I put a sleep in just to make absolutely sure that I wasn't reading back the value before it was actually set, so lets set it and read back:
glLineWidth(8.0f);
{
// local testing, #include <thread> and <chrono>
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
}
glGetFloatv(GL_LINE_WIDTH, currLineWidth);
std::cout << "line width after: " << currLineWidth[0] << std::endl;
// since this is in my draw loop I'm just resetting again, removing
// doesn't change the impact
glLineWidth(1.0f);
My application is not setting glEnable(GL_LINE_SMOOTH)
or anything, but it seems the line width never actually changes. I'm confused because I get the following print out:
line width range: 1, 10
line width before: 1
line width after: 1
It should be that if line width range
is reporting a range [1, 10]
, that something like glLineWidth(8.0f)
would be all I need to actually use it...right?
I don't think this is relevant, but I'm using an OpenGL 3.3 core profile, with an underlying glDrawElements(GL_LINES, count, GL_UNSIGNED_INT, offset)
in conjunction with a shader program. I omitted that because it adds a lot of code to the question.
Update: Hmmm. It seems that maybe the driver has disabled it internally or something.
glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, lineWidthRange);
std::cout << "smooth line width range: " << lineWidthRange[0] << ", " << lineWidthRange[1] << std::endl;
On this box it returns [1, 1]
, so even if I glDisable(GL_LINE_SMOOTH)
, it seems I still won't be able to use it.
I believe you need to use the compatibility profile for line width to work. It is not supported in core. If core is used you can do your own thick lines by using a screen aligned quads system.
hope this helps.