1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39

void drawCube(int x, int y, int z, float r, float g, float b) {
glBegin(GL_QUADS);
glColor3f(r, g, b);
glVertex3f(x * CUBE_SIZE, y * CUBE_SIZE + CUBE_SIZE, z * CUBE_SIZE);
glVertex3f(x * CUBE_SIZE, y * CUBE_SIZE + CUBE_SIZE, z * CUBE_SIZE + CUBE_SIZE);
glVertex3f(x * CUBE_SIZE + CUBE_SIZE, y * CUBE_SIZE + CUBE_SIZE, z * CUBE_SIZE + CUBE_SIZE);
glVertex3f(x * CUBE_SIZE + CUBE_SIZE, y * CUBE_SIZE + CUBE_SIZE, z * CUBE_SIZE);
glColor3f(r / 2, g / 2, b / 2);
glVertex3f(x * CUBE_SIZE, y * CUBE_SIZE, z * CUBE_SIZE);
glVertex3f(x * CUBE_SIZE, y * CUBE_SIZE, z * CUBE_SIZE + CUBE_SIZE);
glVertex3f(x * CUBE_SIZE + CUBE_SIZE, y * CUBE_SIZE, z * CUBE_SIZE + CUBE_SIZE);
glVertex3f(x * CUBE_SIZE + CUBE_SIZE, y * CUBE_SIZE, z * CUBE_SIZE);
glColor3f(r * .75, g * .75, b * .75);
glVertex3f(x * CUBE_SIZE, y * CUBE_SIZE, z * CUBE_SIZE);
glVertex3f(x * CUBE_SIZE, y * CUBE_SIZE, z * CUBE_SIZE + CUBE_SIZE);
glVertex3f(x * CUBE_SIZE, y * CUBE_SIZE + CUBE_SIZE, z * CUBE_SIZE + CUBE_SIZE);
glVertex3f(x * CUBE_SIZE, y * CUBE_SIZE + CUBE_SIZE, z * CUBE_SIZE);
glColor3f(r * .75, g * .75, b * .75);
glVertex3f(x * CUBE_SIZE, y * CUBE_SIZE, z * CUBE_SIZE);
glVertex3f(x * CUBE_SIZE + CUBE_SIZE, y * CUBE_SIZE, z * CUBE_SIZE);
glVertex3f(x * CUBE_SIZE + CUBE_SIZE, y * CUBE_SIZE + CUBE_SIZE, z * CUBE_SIZE);
glVertex3f(x * CUBE_SIZE, y * CUBE_SIZE + CUBE_SIZE, z * CUBE_SIZE);
glColor3f(r * .75, g * .75, b * .75);
glVertex3f(x * CUBE_SIZE + CUBE_SIZE, y * CUBE_SIZE, z * CUBE_SIZE + CUBE_SIZE);
glVertex3f(x * CUBE_SIZE + CUBE_SIZE, y * CUBE_SIZE, z * CUBE_SIZE);
glVertex3f(x * CUBE_SIZE + CUBE_SIZE, y * CUBE_SIZE + CUBE_SIZE, z * CUBE_SIZE);
glVertex3f(x * CUBE_SIZE + CUBE_SIZE, y * CUBE_SIZE + CUBE_SIZE, z * CUBE_SIZE + CUBE_SIZE);
glColor3f(r * .75, g * .75, b * .75);
glVertex3f(x * CUBE_SIZE + CUBE_SIZE, y * CUBE_SIZE, z * CUBE_SIZE + CUBE_SIZE);
glVertex3f(x * CUBE_SIZE, y * CUBE_SIZE, z * CUBE_SIZE + CUBE_SIZE);
glVertex3f(x * CUBE_SIZE, y * CUBE_SIZE + CUBE_SIZE, z * CUBE_SIZE + CUBE_SIZE);
glVertex3f(x * CUBE_SIZE + CUBE_SIZE, y * CUBE_SIZE + CUBE_SIZE, z * CUBE_SIZE + CUBE_SIZE);
glEnd();
}
