driver 在 "supported" 时实际使用 GL_LINE_WIDTH
Actually using GL_LINE_WIDTH when "supported" by driver
我知道 driver 不需要支持可变线宽,查询 driver 支持的方式显示为 :
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;
查询当前线宽:
GLfloat currLineWidth[1] = {0.0f};
glGetFloatv(GL_LINE_WIDTH, currLineWidth);
std::cout << "line width before: " << currLineWidth[0] << std::endl;
所以现在,它应该并且确实会报告当前线宽的 1
。我只是为了绝对确保我没有在实际设置之前读回值,所以让我们设置它并读回:
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);
我的应用程序没有设置 glEnable(GL_LINE_SMOOTH)
或任何东西,但线宽似乎从未真正改变过。我很困惑,因为我打印出以下内容:
line width range: 1, 10
line width before: 1
line width after: 1
应该 如果 line width range
报告的范围是 [1, 10]
,那么 glLineWidth(8.0f)
之类的东西实际上就是我所需要的使用它...对吗?
我认为这无关紧要,但我使用的是 OpenGL 3.3 核心配置文件,底层 glDrawElements(GL_LINES, count, GL_UNSIGNED_INT, offset)
与着色器程序结合使用。我省略了它,因为它为问题添加了很多代码。
更新:嗯。看来 driver 可能在内部或其他方面禁用了它。
glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, lineWidthRange);
std::cout << "smooth line width range: " << lineWidthRange[0] << ", " << lineWidthRange[1] << std::endl;
这个盒子上returns[1, 1]
,所以就算我glDisable(GL_LINE_SMOOTH)
,好像还是用不上
我认为您需要使用线宽的兼容性配置文件才能工作。
它在核心中不受支持。如果使用核心,你可以做你自己的粗线
通过使用屏幕对齐的四边形系统。
希望对您有所帮助。
我知道 driver 不需要支持可变线宽,查询 driver 支持的方式显示为
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;
查询当前线宽:
GLfloat currLineWidth[1] = {0.0f};
glGetFloatv(GL_LINE_WIDTH, currLineWidth);
std::cout << "line width before: " << currLineWidth[0] << std::endl;
所以现在,它应该并且确实会报告当前线宽的 1
。我只是为了绝对确保我没有在实际设置之前读回值,所以让我们设置它并读回:
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);
我的应用程序没有设置 glEnable(GL_LINE_SMOOTH)
或任何东西,但线宽似乎从未真正改变过。我很困惑,因为我打印出以下内容:
line width range: 1, 10
line width before: 1
line width after: 1
应该 如果 line width range
报告的范围是 [1, 10]
,那么 glLineWidth(8.0f)
之类的东西实际上就是我所需要的使用它...对吗?
我认为这无关紧要,但我使用的是 OpenGL 3.3 核心配置文件,底层 glDrawElements(GL_LINES, count, GL_UNSIGNED_INT, offset)
与着色器程序结合使用。我省略了它,因为它为问题添加了很多代码。
更新:嗯。看来 driver 可能在内部或其他方面禁用了它。
glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, lineWidthRange);
std::cout << "smooth line width range: " << lineWidthRange[0] << ", " << lineWidthRange[1] << std::endl;
这个盒子上returns[1, 1]
,所以就算我glDisable(GL_LINE_SMOOTH)
,好像还是用不上
我认为您需要使用线宽的兼容性配置文件才能工作。 它在核心中不受支持。如果使用核心,你可以做你自己的粗线 通过使用屏幕对齐的四边形系统。
希望对您有所帮助。