用OpenGL绘制多边形时,绘制的图形变形了void MyDraw(){ glColor3f(1.0, 1.0, 1.0); glBegin(GL_POLYGON); glVertex2i(380, 380); glVertex2i(320, 410); glVertex2i(180, 280); glVertex2i(90, 330); glVertex2i(50, 310); glVertex2i(50, 150); glVer
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/21 09:00:40
用OpenGL绘制多边形时,绘制的图形变形了void MyDraw(){ glColor3f(1.0, 1.0, 1.0); glBegin(GL_POLYGON); glVertex2i(380, 380); glVertex2i(320, 410); glVertex2i(180, 280); glVertex2i(90, 330); glVertex2i(50, 310); glVertex2i(50, 150); glVer
用OpenGL绘制多边形时,绘制的图形变形了
void MyDraw()
{
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex2i(380, 380);
glVertex2i(320, 410);
glVertex2i(180, 280);
glVertex2i(90, 330);
glVertex2i(50, 310);
glVertex2i(50, 150);
glVertex2i(90, 130);
glVertex2i(180, 180);
glVertex2i(320, 50);
glVertex2i(380, 80);
glEnd();
glFlush();
}
本来应该只有红色线框内才是白的,小弟不知原因,
用OpenGL绘制多边形时,绘制的图形变形了void MyDraw(){ glColor3f(1.0, 1.0, 1.0); glBegin(GL_POLYGON); glVertex2i(380, 380); glVertex2i(320, 410); glVertex2i(180, 280); glVertex2i(90, 330); glVertex2i(50, 310); glVertex2i(50, 150); glVer
OpenGL只能绘制凸多边形,你红线勾出的显然是个凹多边形,所以绘制错误.
解决方法:
1.可以从中间将这个凹多边形分割为两个凸多边形,分两次画出:
比如:
glBegin(GL_POLYGON);
//左边多边形的点
glEnd();
glBegin(GL_POLYGON);
//右边多边形的点
glEnd();
2.可以用GLU的网格化对象,将此凹多边形三角化,并画出.