用OPENGL如何给立方体各个面着色glutWireCube(1.0)用上述语句如何给已经画出来的立方体的各个面着色.六个面的颜色各不相同.答的好的快的有追加.
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/28 22:59:15
用OPENGL如何给立方体各个面着色glutWireCube(1.0)用上述语句如何给已经画出来的立方体的各个面着色.六个面的颜色各不相同.答的好的快的有追加.
用OPENGL如何给立方体各个面着色
glutWireCube(1.0)
用上述语句如何给已经画出来的立方体的各个面着色.六个面的颜色各不相同.答的好的快的有追加.
用OPENGL如何给立方体各个面着色glutWireCube(1.0)用上述语句如何给已经画出来的立方体的各个面着色.六个面的颜色各不相同.答的好的快的有追加.
GLfloat color[6][3]={{1.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,1.0},
{1.0,1.0,0.0},{1.0,0.0,1.0},{0.0,1.0,1.0}};
int tempc[3][3][6];
GLfloat xRot = 10.0f;
GLfloat yRot = 10.0f;
int rotateType=0;
int rotateOK=0;
int rotateRate=50;
int rotate=0;
void drawcube(int cl[6])
{
glBegin(GL_QUADS);
glColor3fv(color[cl[0]]);
glVertex3f(0.14f,-0.14f,-0.14f);
glVertex3f(0.14f,0.14f,-0.14f);
glVertex3f(0.14f,0.14f,0.14f);
glVertex3f(0.14f,-0.14f,0.14f);
glColor3fv(color[cl[1]]);
glVertex3f(-0.14f,-0.14f,0.14f);
glVertex3f(-0.14f,0.14f,0.14f);
glVertex3f(-0.14f,0.14f,-0.14f);
glVertex3f(-0.14f,-0.14f,-0.14f);
glColor3fv(color[cl[2]]);
glVertex3f(-0.14f,0.14f,0.14f);
glVertex3f(-0.14f,-0.14f,0.14f);
glVertex3f(0.14f,-0.14f,0.14f);
glVertex3f(0.14f,0.14f,0.14f);
glColor3fv(color[cl[3]]);
glVertex3f(-0.14f,0.14f,-0.14f);
glVertex3f(0.14f,0.14f,-0.14f);
glVertex3f(0.14f,-0.14f,-0.14f);
glVertex3f(-0.14f,-0.14f,-0.14f);
glColor3fv(color[cl[4]]);
glVertex3f(-0.14f,0.14f,-0.14f);
glVertex3f(-0.14f,0.14f,0.14f);
glVertex3f(0.14f,0.14f,0.14f);
glVertex3f(0.14f,0.14f,-0.14f);
glColor3fv(color[cl[5]]);
glVertex3f(-0.14f,-0.14f,-0.14f);
glVertex3f(0.14f,-0.14f,-0.14f);
glVertex3f(0.14f,-0.14f,0.14f);
glVertex3f(-0.14f,-0.14f,0.14f);
glEnd();
glFlush();
}