Discussion:
This program adds two more functions to our simple
program: MousePress and MouseMove. MousePress detects the left mouse
button being pressed and sets a global variable pair xAbs and yAbs.
MouseMove detects movement while the button is depressed and rotates the
sphere by 1 degree about the x or y axis for each pixel across or
up/down the mouse is moved. In this demo, only rotation is affected, but
this code can easily be changed to allow forward or side-to-side
movement in the same framework.
Sample code:
Click here to see the sample code: mouse.c
Executable example:
Click here for a running demo: mouse.exe
|