Roll Pitch and Yaw - Airplane style rotation

Hello,

I have searched a lot for this problem online, but I am yet to find a solution to it.

How can I implement airplane style rotations in OpenGL (roll, pitch, and yaw),

Right now, I am using glRotatef as:

glRotatef(roty, 0, 1, 0);
glRotatef(rotx, 1, 0, 0);

However, after rotating along y (roll), x-rotation is NOT a pitch from the plane’s perspective (local axes?). Rather, it’s a rotation around x, which is as expected.

I am wondering how to achieve the airplane style rotations… any pointers will be appreciated.

Conceptual order: HPR (Heading, then pitch, then roll). Heading (being a rotation around an “up”-axis), pitch (being a rotation around a “right”-axis), and roll (being a rotation about a “forward”-axis). As usual, when thinking about position an object within a coordinate frame vs. transforming between coordinate frames, you need to flip the transform order.