# OpenGL glRotate and glTranslate

I am trying to rotate a cube around an axis and what I am doing:

```
glTranslatef(0.0f, 0.0f, -60.0f);
glRotatef(angle, 0.0f, 1.0f, 0.0f);
```

I expect it to move by -60 and rotate around the y-axis in a circle, but instead, it just rotates around it at -60 coordinates. When I write it like this:

```
glRotatef(angle, 0.0f, 1.0f, 0.0f);
glTranslatef(0.0f, 0.0f, -60.0f);
```

I am getting what I need, but I donβt understand why? Why do they do the opposite? Can someone explain.

source to share

When applied, the transform is applied locally. Think of it as the coordinate system that you move. You start with a coordinate system that represents your view, and then you transform that coordinate system relative to yourself. So, in the first case, you translate the -60 coordinate system along the Z-axis of the coordinate system, and then you rotate the coordinate system around the new Y-axis at a new origin. Everything you draw is then drawn in this new coordinate system.

It actually provides an easier way to think about conversions once you're used to it. You do not need to consider two separate coordinate systems: one for the coordinate system in which the transforms are applied, and one for the coordinate system in which the geometry is executed.

source to share