# How to rotate an object in OpenGL on the X, Y and Z axis on its local coordinates?

I've read multiple tutorials, but I still can't understand how do I properly rotate an object in 3D space on all 3 axis at once. For example, I'd like to give the object a pitch of 60 degrees, yaw of 20 degrees and roll of 70 degrees. How can I properly do this in OpenGL, preferrably using GLM?

• "I'd like to give the object a pitch of 60 degrees, yaw of 20 degrees and roll of 70 degrees." Why? Why do you want to do this thing? – Nicol Bolas Jun 17 at 5:36
• OpenGL has nothing to do with that. GLM might very well regarding the implementation (but in turns has nothing to do with OpenGL either). But ultimately that's a purely mathematic problem, the practical implementation of which depends on a lot more things than if you're using GLM. And even the mathematical theory of which depends on a few other unclarities, e.g. what "pitch", "yaw" and "roll" even mean in your context and what exactly you want your object to behave like. – Chris says Reinstate Monica Jun 17 at 11:17
• @Nicol Bolas Because those are all the three rotation values that an object can take at a time. Such thing is needed for example, in games with planes and helicopters, since they can turn around these 3 axis all at the same time. – John Jun 17 at 14:27
• @Nicol Bolas Nevermind, I just realised that the answer is simpler than I first thought. I think that simply creating a rotation matrix for each axis and then multiplying them would do the trick. – John Jun 17 at 17:37
• And then you'll be back tomorrow asking about Gimbal Lock or other similar Euler angle problems. – Nicol Bolas Jun 17 at 17:39