Hello,

I need to perform rotation of the canvas or scene based on mouse click and drag. I am still not sure whether the method I've used for computing the rotation angle based on mouse events is correct or not. I have the following projection settings

Code :
 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();
 glRotatef(atan2f(currentPoint.y-previousPoint.y, currentPoint.x-previousPoint.x), 0.0, 0.0, -1.0);
 glOrtho(centerp.x-screenwidth/2, centerp.x+screenwidth/2, 
         centerp.y-screenheight/2, centerp.y+screenheight/2, 1.0, 10000.0);

With the above projection, I am able to produce rotation along z-axis. i.e. I can rotate the canvas clockwise, or anti-clockwise direction in 2D. The same didn't work for 3D. I tried using

Code :
glRotatef(atan2f(currentPoint.y-previousPoint.y, currentPoint.x-previousPoint.x), 1.0, 1.0, -1.0);

With this setting, I get rotation very fast and only in one direction (i.e. diagonally). It doesn't depend on the mouse positions. Click anywhere and drag, it rotates diagonally from top-right to bottom-left. What am I missing? How can I rotate entire scene (canvas) in 3D?

Any suggestions or comments?

Thanks & Regards
Rakesh Patil