PDA

View Full Version : Transformation in Opengl



Ali S. Alfaraj
09-16-2010, 08:11 PM
Good day all,

I wrote a code, in Opengl, to display an object (e.g. cube) in the display window.

What I want to do next is to rotate this object around the X, Y and Z axis based on the X and Y coordinates of the mouse.

For example, If I clicked on the left button of the mouse and dragged the mouse(wile pressing the left button) to the right, the object should rotate around the Y axis with a certain amount.

Can anyone help me with that.

Best regards,
Ali

Ali S. Alfaraj
09-17-2010, 05:43 PM
Hi friends,

Is there something not clear about my question?

david_f_knight
09-17-2010, 06:22 PM
Mostly your question has to do with your operating system rather than OpenGL. How you obtain your mouse coordinates depends on what operating system you are using, not OpenGL. For example, Windows sends the WM_MOUSEMOVE message whenever the mouse is moved and the WM_LBUTTONDOWN message when the left mouse button is pressed and the WM_LBUTTONUP message when the left mouse button is released. I don't know how other operating systems communicate the mouse position and state to you.

Once you have your mouse information, typically you would construct a rotation matrix based on that, and send that matrix to OpenGL to transform the position of the vertices of your object. How you do this depends on what version of OpenGL you are using.

So, you need to provide more information. Also note that there are other forums here, specific to which operating system you are using (Windows, Linux, and Macintosh are represented), that would be a better place to ask questions about interacting with your mouse.

There are probably some tutorials around the internet that you could find that have examples of what you are asking about for the operating system you are using.