且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使openGL线连接

更新时间:2023-11-22 22:45:16

http://answers.oreilly.com/topic/949-how-to-work-around-the-iphones-anti-aliasing-limitations/ =nofollow>此处显示如何实现四舍五入线帽和抗锯齿线使用纹理技巧。


Right now I'v created a polygon, then I do the same thing but with line_loop to draw the outline. My issue right now is if I set the line thickness to high, the lines arn't connected. Their ends would need to be (linewidth) longer... is there a way to fix this?

Thanks

glMatrixMode (GL_PROJECTION);
        glLoadIdentity ();
        glOrtho (0, 600, 600, 0, 0, 1);
        glMatrixMode (GL_MODELVIEW);
......
glLineWidth(5.0);
glTranslatef(250,250,0);
glRotated(x,0,0,50.0);
    glBegin(GL_POLYGON); //Begin quadrilateral coordinates
    //Trapezoid
    glColor3f(255,0,0);
glVertex2f(0,0);
glVertex2f(100,0);
glVertex2f(100,100);
glVertex2f(50,50);
glVertex2f(0,100);

    glEnd(); //End quadrilateral coordinates

    glBegin(GL_LINE_LOOP); //Begin quadrilateral coordinates

    //Trapezoid
    glColor3f(0,255,0);
    glVertex2f(0,0);
    glVertex2f(100,0);
    glVertex2f(100,100);
    glVertex2f(50,50);
    glVertex2f(0,100);

    glEnd(); //End quadrilateral coordinates

The article here shows how to achieve rounded line caps and antialised lines using a texture trick.