用OPENGL如何给立方体各个面着色

1个回答

  • 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();

    }