glRotatef rotation never applied to 3d cube

I have a floating cube that I want to rotate around the Y axis. The cube renders fine, the proper size, the proper coordinate, the proper texture/faces, etc.

However, the rotation is never applied. My update logic calculates a new rotation value, between 0 and 360.

// Set the coordinates, rotate Y axis
GL11.glTranslatef(x,y,z);
GL11.glRotatef(rotation, 0, 1f, 0);

// Each cube face rendered, etc...
GL11.glColor3f( //...
GL11.glTexCoord2f(//..
GL11.glVertex3f//..


No matter what combination I've tried, the cube never changes it's rotation.

Update Per a comment, I was using glBegin outside the glRotatef and the comment advised that I use glPush/Pop:

GL11.glPushMatrix();
GL11.glRotatef(rotation, 0f, 1f, 0);
GL11.glPopMatrix();

GL11.glEnd();

• glRotatef shouldn't be inside glBegin. From what you have shown it seems so, but you need to show us the rest of the code to be sure. Nov 30 '13 at 20:23
• I was using glBegin before the rotate method, but when I try it after, the whole block fails to render. Nov 30 '13 at 20:46
• your problem is with your loop. You need to understand the matrix stack. But anyway I recommend you abandon the whole OpenGL 1.1 thing because it's useless and start with OpenGL with shaders it will make much more sense. Nov 30 '13 at 20:49
• How can I resolve the problem with the loop then? Nov 30 '13 at 20:56
• you need to understand the matrix stack. specifically glPush, glPop Nov 30 '13 at 21:06

Your problem is the placement of your glPopMatrix call. The current matrix on the stack only affects drawn objects while it is current, but you're drawing after you pop the matrix.

The correct order is:

• glPushMatrix to go to a new current matrix on the stack.
• Apply transforms (translate/rotate).
• Draw objects.
• glPopMatrix to restore the previous matrix.

Do you see why this is? If not, I'd advise you to review some documentation about how the GL matrix stack works.

• I've been reading a lot about the push/pop and rotation methods, I've looked at a ton of example code, and I even tried your example order but I either end up with nothing rendered, or a the block rendered without any rotation. pste.me/C9lTD Nov 30 '13 at 22:44
• I've finally worked it out. This method worked fine the trouble was that my block was rotating on the offset, meaning it was making a big circle around the map and not its own Y. I turned all blocks invisible to see it during debugging and realized. The final code required two translate commands to rotate on the proper axis. pste.me/QeRyi Thanks Nov 30 '13 at 23:52