gpt4 book ai didi

c++ - 使用 OpenGL 绘制连接线

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:00:40 26 4
gpt4 key购买 nike

<分区>

我正在使用 OpenGL 绘制凸多边形。然后我做同样的事情但使用 GL_LINE_LOOP。我遇到的问题是线路并不总是连接的。如何确保线路始终保持连接状态?

在下面的照片中,Iv 以绿色突出显示连接的角,以红色突出显示不连接的角。我希望它们都像绿色的。

http://img249.imageshack.us/i/notconnected.png/

谢谢

glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
x ++;
glLineWidth(50.0);

glPushMatrix();
glTranslatef(250,250,0);
glBegin(GL_POLYGON); //Begin quadrilateral coordinates

//Trapezoid
glColor3f(255,0,0);
glVertex2f(-10,0);
glVertex2f(50,0);
glColor3f(255,100,0);
glVertex2f(100,50);
glVertex2f(mouse.x - 250,mouse.y - 250);
glVertex2f(-30,50);

glEnd(); //End quadrilateral coordinates

glBegin(GL_LINE_LOOP); //Begin quadrilateral coordinates

//Trapezoid
glColor3f(0,0,255);
glVertex2f(-10,0);
glVertex2f(50,0);

glVertex2f(100,50);
glVertex2f(mouse.x - 250,mouse.y - 250);
glVertex2f(-30,50);

glEnd(); //End quadrilateral coordinates

glPopMatrix();
glBegin(GL_QUADS); //Begin quadrilateral coordinates

glVertex2f(0,0);
glColor3f(0,255,0);
glVertex2f(150,0);
glVertex2f(150,150);
glColor3f(255,0,0);
glVertex2f(0,150);


glEnd(); //End quadrilateral coordinates

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