I have a 3d object that I wish to be able to rotate around in 3d. The easiest way is to directly translate X and Y mouse motion to rotation about the Y and X axes, but if t
Create an accumulator matrix and initialize it with the identity.
Each frame, apply that to your modelview/world matrix state before drawing the object.
Upon mouse motion, construct a rotation matrix about the X axis with some sensitivity_constant * delta_x. Construct another rotation matrix about the Y axis for the other component. Multiply one, then the other onto the accumulator.
The accumulator will change as you move the mouse. When drawing, it will orient the object as you expect.
Also, the person talking about quaternions is right; this will look good only for small incremental changes. If you drag it quickly on a diagonal, it won't rotate quite the way you expect.