Any can please give opengl c++ code for Rubik’s cube…
i created rubik’s cube…
but i cant rotate each slice…
void colorcube()
{
for(i=0;i<=.66;i=i+.22)
{
for(j=0;j<=.66;j=j+.22)
{
for(k=0;k<=.66;k=k+.22)
{
glColor3fv(colors[1]);
glBegin(GL_POLYGON);
glVertex3f(i-.3,j-.3,k-.3);
glVertex3f(i-.3,j-.1,k-.3);
glVertex3f(i-.1,j-.1,k-.3);
glVertex3f(i-.1,j-.3,k-.3);
glEnd();
glColor3fv(colors[2]);
glBegin(GL_POLYGON);
glVertex3f(i-.3,j-.3,k-.3);
glVertex3f(i-.3,j-.1,k-.3);
glVertex3f(i-.3,j-.1,k-.1);
glVertex3f(i-.3,j-.3,k-.1);
glEnd();
glColor3fv(colors[3]);
glBegin(GL_POLYGON);
glVertex3f(i-.3,j-.3,k-.3);
glVertex3f(i-.3,j-.3,k-.1);
glVertex3f(i-.1,j-.3,k-.1);
glVertex3f(i-.1,j-.3,k-.3);
glEnd();
glColor3fv(colors[4]);
glBegin(GL_POLYGON);
glVertex3f(i-.1,j-.1,k-.3);
glVertex3f(i-.1,j-.3,k-.3);
glVertex3f(i-.1,j-.3,k-.1);
glVertex3f(i-.1,j-.1,k-.1);
glEnd();
glBegin(GL_POLYGON);
glColor3fv(colors[5]);
glVertex3f(i-.1,j-.1,k-.1);
glVertex3f(i-.3,j-.1,k-.1);
glVertex3f(i-.3,j-.3,k-.1);
glVertex3f(i-.1,j-.3,k-.1);
glEnd();
glBegin(GL_POLYGON);
glColor3fv(colors[6]);
glVertex3f(i-.1,j-.1,k-.1);
glVertex3f(i-.3,j-.1,k-.1);
glVertex3f(i-.3,j-.1,k-.3);
glVertex3f(i-.1,j-.1,k-.3);
glEnd();
}
}
}
}