OpenGL 线宽

2021-12-19 00:00:00 opengl line c++

在我的 OpenGL 应用程序中,它不会让我画一条大于十像素宽的线.有没有办法让它画十个像素以上?

In my OpenGL app, it won't let me draw a line greater then ten pixels wide. Is there a way to make it draw more than ten pixels?

void OGL_Renderer::drawLine(int x, int y, int x2, int y2, int r, int g, int b, int a, int line_width)
{   
    glColor4ub(r, g, b, a);

    glLineWidth((GLfloat)line_width);
    glBegin(GL_LINES);
    glVertex2i(x, y);
    glVertex2i(x2, y2);
    glEnd();
    glLineWidth(1.0f);
}

推荐答案

您可以尝试绘制四边形.使其宽度与您希望的线条一样长,高度与所需的线条宽度相同,然后旋转并将其定位到线条所在的位置.

You could try drawing a quad. Make it as wide as you want your line to be long, and tall as the line width you need, then rotate and position it where the line would go.

相关文章