cube rollover

Hi,

I want to make a cube rollover in opengl space, something like(http://www.youtube.com/watch?v=4IEFC_Y3nrA&feature=related). I made something like this for Y axes:

glPushMatrix();
glTranslate(0, _y, 0);
glRotatef(_rot, -1, 0, 0, 0);//rotate
glTranslate(0, -CUBE_HALF_SIZE, CUBE_HALF_SIZE);//around point

if(_rot > 180)
{
_rot = 90;
_y = _y + CUBE_SIZE;
}

This is working, but is not ok, because the texture will not be shown correctly after _rot = 90, because the object is rotated to 90 again. So does anyone knows how to do it?

Thanks, in advance!

You should not reset the rotation. The only point when you can safely reset rotation is at 360 degrees. It is more an algorithmic problem than an OpenGL issue.

You should simply store the current rotation and use that afterwards.

I tried your idea, but it’s not working.