Rubik's Cube

Commands:

-d dimension : specify the dimension of the cube, it's n*n*n
-t turn_time : how much time to take a turn
-s scramble_times: how many turns to scramble the cube
-f : to solve the cube in animation
-r: reset the cube to a solved state
-t: toggle texture (not so well, i dunno why i can only load half of the texture maps)
-p: pause or resume the animation

Implementation:

I didn't treat it as a combination of small cubes but of small squares. Basically I have 6 facets, each of which is consisted of an n*n array. Each element in these arrays stores the color and texture information, as well as the rotate angle of the small square it represents.

I wanted to use display list, but I dunno why it could not display texture. I have to replace the glCallList() with actual rendering code. I used glPushMatrix and glPopMatrix extensively to preserve the matrix of each little square.

The textures are a bit off. First it takes a long time to load all the textures (since they look identical, i dun see why we have to use all the 54 textures, anyway...). And I simply repeat mapping the same set of textures to larger cubes which makes the logo appears several times( i guess it's the white5.raw?). *I maybe mess up the orientations of the facets so 3 of them do not display the textures. What I don't know is why the colors of the squares and the colors of their textures are not the same.

The 3d manipulation is odd. I referenced 3D Controls and chose Vector and Roll because it's natural with opengl. But the biggest problem is I don't how to combine each rotation. What I do is turn off glLoadIdentity() so the rotations can be accumulated. But it doesn't work when refreshing the screen, say animation or resizing... I also tried to use Elevation and Azimuth to represent rotations, but I don't have time to make it work well. BTW, powerful as Quaternion is, it's too complicated for me to figure out :'( 
 

*Well, I know why it's do weird now. I made a silly mistake in indexing the textures to each facet :(