【发布时间】:2019-10-02 03:23:02
【问题描述】:
附加图像是我想要做的:
但是,我的代码给了我以下模式:
谁能指引我正确的方向?
void drawPattern(float xPos, float yPos, float length){
glColor3f(0.0, 1.0, 0.0);
// Drawing Square
glBegin(GL_POLYGON);
glVertex2f(xPos + length, yPos);
glVertex2f(xPos, yPos);
glVertex2f(xPos , yPos + length);
glVertex2f(xPos + length , yPos + length);
glEnd();
glColor3f(0,0,1);
float halfPi = 0.5 * PI;
//Drawing Bottom Left Circle
glBegin(GL_LINE_LOOP);
for (float angle = 0.0; angle < 90 * 0.01745329; angle += 0.01745329){
glVertex2f( xPos + (length/2)*cos(angle), yPos + (length/2)*sin(angle));
}
glEnd();
//Drawing Top Right Circle
glBegin(GL_LINE_LOOP);
for (float angle = 0.0; angle < 90 * 0.01745329; angle += 0.01745329){
glVertex2f( xPos + length/2 + (length/2)*cos(angle), yPos + length/2 + (length/2)*sin(angle));
}
glEnd();
}
【问题讨论】: