- Online Community Forums » Programming Questions » Problem with Rubik Cube

This thread is locked; no one can reply to it. rss feed Print
Problem with Rubik Cube
Member #16,799
January 2018

Hi all:
I am back at it again! Hope all is well.
This time it will be a rubik cube that I need help on.
I have posted the files above. I tried to zip them but had no luck.
This is my problem:

When you run the program the cube will start to rotate.
This is fine. I have it set up to press the 's' key so I have a still
cube to hopefully begin rotating slices.
It should then show white on top, blue on the right side and red on
the left side. What happens is the left side is all white.
If you then press the 'r' key to begin rotating again what was all white on
left side is now blue just like the right side.

I have no idea what is happening except there is something going on
between texture[0] and texture[5].

The program is quite large now. I want to put it in an array after I
get it all working right. I did a search on the internet and found
some rubik cube programs but did not look like I wanted, so I made
my own.
If someone has the time to take a look I would be thankful.

Dizzy Egg
Member #10,824
March 2009

Firstly, you're only declaring 5 textures, you need 6:

GLuint texture[6]; //YOU HAD THIS AS 5!!

Secondly, you need to fix your rotate code:

    if(rotate == false)
         glRotatef(45.0, 1.0, 0.0, 0.0);
         glRotatef(45.0, 0.0, 1.0, 0.0);

That should get you where you need to be!

Actually, you don't need to change your rotate code, that's up to you!!

Please check out my songs:

Member #16,799
January 2018

Hi Dizzy:
I cannot believe I did that! That is unreal!

I had texture[5]; Then right beside that, I had load 6 textures.
OK, I made a mistake, but why did the rotation work so well since
I was missing one. In my code I said that I needed 6. I guess that
is what saved me. I guess I need an eye exam!

Also, some months ago I sent you a really fast program that loaded
obj files. Were you able to do anything with it? Just checking.

Thanks for looking at my code. I hope you didn't have to spend much
time on it. Thanks again, have a great day!

Go to: