As noted from the discussion of the mouse function, the
Boolean variable dragging indicates whether the left button is down. Also, the variables startX and startY hold the mouse location when the button was pressed.
We allow the angle of rotation about the x-axis to vary from -90 degrees to 90 degrees. Thus, the amount we use in updating the angle is a fractional part of 90 degrees. The fraction, which we store in percentChangeY, is the amount the mouse moved in the Y direction from its initial position startY divided by the height of the device window. Note that a contiuous stream of update values is being computed while the mouse is in motion. We add each change to currentAngleX to obtain a new angle that is stored in updatedAngleX. The variable updatedAngleX is the one that is referenced in our display function with a call to glRotated.
Similar computations are performed for updating the angle of rotation about the y axis. But in this case, we allow the angle of rotation to be any value and, in turn, we use a fractional portion of 360 degrees for updating the angle. Also, movement in the x direction is used in computing the change in the angle.