Most likely you're rendering on a fullscreen antialiasing capable framebuffer (multisampling) and not hitting the exact pixel centers. So your line actually covers into two rows/columns of pixels giving that effect. Try what happens if you forcefully disable antialiasing (using the GPU driver control panel).
line vertex is too thick (no matter what the width is)
-
29-06-2022 - |
Pergunta
I am drawing 3 lines with a function I made (simplified, working example):
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();
}
It does it's job nicely, but I can't get good 1 pixel sized lines. No matter what I set the width too.
This is how I call the function:
DrawPoly(0.001,0x77777777,ofPoint(150,150),ofPoint(200,150),ofPoint(200,200),ofPoint(150,200));
and this is the result (and no matter how low I set the width!):
I don't understand why this happens, I'm trying to switch from directX and the equivalent code gives the result I need:
How can I fix this? This happens to all my line/poly shape code! :(
Solução
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow