gpt4 book ai didi

c++ - 线顶点太粗(不管宽度是多少)

转载 作者:行者123 更新时间:2023-11-28 00:40:54 25 4
gpt4 key购买 nike

我正在用我制作的功能绘制 3 条线(简化的工作示例):

template<class... Args> inline void DrawPoly(float width , int color, Args... args)
{
glLineWidth(width);
ofSetHexColor(color);
glBegin(GL_LINES);
std::array<ofPoint, sizeof...(args)> list = {args...};
for(size_t i = 1, j = list.size(); i < j; ++i)
{
glVertex3f(list[i-1].x, list[i-1].y, list[i-1].z);
glVertex3f(list[i].x, list[i].y, list[i].z);
}
glEnd();
}

它做得很好,但我无法获得 1 像素大小的线条。不管我设置宽度太。

我是这样调用函数的:

DrawPoly(0.001,0x77777777,ofPoint(150,150),ofPoint(200,150),ofPoint(200,200),ofPoint(150,200));

这是结果(无论我将宽度设置多低!):

enter image description here

我不明白为什么会这样,我正在尝试从 directX 切换,等效代码给出了我需要的结果:

enter image description here

我该如何解决这个问题?这发生在我所有的线/多边形代码上! :(

最佳答案

很可能您正在全屏抗锯齿帧缓冲区(多重采样)上进行渲染,而不是精确的像素中心。因此,您的线条实际上覆盖了两行/两列像素,从而产生这种效果。尝试强制禁用抗锯齿(使用 GPU 驱动程序控制面板)会发生什么情况。

关于c++ - 线顶点太粗(不管宽度是多少),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18934262/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com