使openGL线连接 [英] Make openGL lines connected

查看:151
本文介绍了使openGL线连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我创建了一个多边形,然后我做同样的事情,但用line_loop来绘制轮廓。我的问题现在是如果我设置线的厚度为高,线不连接。



感谢



pre> glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,600,600,0,0,1);
glMatrixMode(GL_MODELVIEW);
......
glLineWidth(5.0);
glTranslatef(250,250,0);
glRotated(x,0,050.0);
glBegin(GL_POLYGON); //开始四边形坐标
//梯形
glColor3f(255,0,0);
glVertex2f(0,0);
glVertex2f(100,0);
glVertex2f(100,100);
glVertex2f(50,50);
glVertex2f(0,100);

glEnd(); //结束四边形坐标

glBegin(GL_LINE_LOOP); //开始四边形坐标

//梯形
glColor3f(0,255,0);
glVertex2f(0,0);
glVertex2f(100,0);
glVertex2f(100,100);
glVertex2f(50,50);
glVertex2f(0,100);

glEnd(); //结束四边形坐标


解决方案

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.

这篇关于使openGL线连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆