Mouse Interaction

Bryson R. Payne, M.Ed.

Screen shot of Mouse.c - mouse rotates objectDiscussion:

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


Back to Main Tutorial Page

Last modified December 11, 2000, Bryson R. Payne, bpayne@ngcsu.edu