I have a 3D object displayed in a window, and I want to be able to click on it, and rotate it. I am not sure where to start.
Originally, I had a button system to rotate the object, but I would rather have it be more interactive. Could someone help me with this? Or point me in the right direction?
You might want to try nehe’s picking tutorial, I can’t remember witch one it is so you’ll have to look, but here’s the address http://nehe.gamedev.net/
when the user left clicks store the x,y mouse position;
on each mouse move message - find the difference of the last stored x,y position from the current one - map this to some rotation value (perhaps 2*delta x for rotations about the y axis as an example).
set the last stored x,y value to the current one;
if the left button is down, rotate the object (by whatever number of degrees or radians are obtained by your mapping).
yes, but the entire problem boils down to how to get a value for degrees to a glRotate call using the mouse. The operations to achieve that include nothing more than Windows API calls: namely an WM_LBUTTON_DOWN, WM_MOUSE_MOVE and WM_LBUTTON_UP.
even using glutMouseFunc(), the problem boils down to the method I outlined before.
It’s not a big deal that it’s not an OpenGL question really, I was just making a statement.
Well, actually Aeluned (not to be rude or anything) if you use glut then to use the mouse you use glutMouseFunc(); which is an opengl function.
No it’s not, glut is not opengl it’s just a utility toolkit to make implementing it easier, opengl is a graphics library not a game development library.
The Mouse/keyboard/joystick etc. functions in glut have nothing to do with opengl.