Compaq Visual Fortran: A Guide to Creating Windows Applications

Chapter 17: Interactive OpenGL Applications

17.1 Using a mouse

Many graphics applications, including computer-aided drawing (CAD) programs, computational fluid dynamics programs, and finite element analysis programs, permit the user to interact with the displayed graphics by means of a mouse. Typical interactions include using the mouse to rotate, pan, and zoom the display. Additionally, users can select points to construct objects such as lines, areas, and volumes. In this final chapter, we will learn how to use the mouse for making selections and controlling viewports.

The first example in this chapter, GridView, evolved from the rotating cube example of Chapter 16. In Chapter 16, the rotation of the cube was obtained using a timer to increment the angles of rotation at predetermined intervals of time. For the cube example, it is easy to remove the timer and increment the rotation angles according to whether the mouse is moved from side to side or up and down. When the mouse movement is in the direction of increasing or decreasing x (side to side), the angle of rotation around the z-axis can be incremented or decremented accordingly. The same test is also applied to the y direction (up and down) and the rotation angle around the x-axis is incremented or decremented accordingly. The code required is as follows:

   case (WM_MOUSEMOVE)      ix = LOWORD(lParam)      iy = HIWORD(lParam)      if(RotateX) then       ...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Rotary Indexing Tables
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.