Graphics Reference
In-Depth Information
model, it must support the WC window and the associated transformations. From
Listing 10.7, we see that, at label F, we define a UWB _ BoundingBox object to
represent the WC window. The get/set access functions for the m _ WCWindow are
defined at label A. Because the UI drawing area (drawing device) is supported by
the MFC GUI API ( m _ hAttachedWindow ), the device get/set functions at label
B are implemented by interacting with the m _ hAttachedWindow object. The two
functions at label C implements the WC-to-DC transformations (more details to
follow). The drawing function at label D allows us to visualize the WC window
as a wire-framed rectangle. The function at label E should compute the M w 2 n ma-
trix and load the graphics API with this matrix. Note that this function is a pure
virtual function; since WindowHandler is a graphics API-independent class, we
do not know how to implement this function. This function will be implemented
by the D3DWindowHandler class. Listing 10.8 shows the implementations of the
transformation functions. We see that in both cases, the functions are faithful
implementations of equations we have derived. We will derive Equation (10.19)
in Section 10.5 and discuss how to work with these functions to handle mouse
inputs. Listing 10.9 shows the implementation of the LoadW2NDCXform() func-
tioninthe D3D _ WindowHandler class. From the listing, we observe step-by-step
implementation of Equation (10.10). The computed M w 2 n operator is loaded into
the VIEW ( M V ) matrix processor of the D3D API.
Tutorial 10.9. Working with UWBGL _ D3D _ Lib10
Tutorial 10.9.
Project Name:
D3D _ WCSupport
Library Support:
UWB _ MFC _ Lib1
UWB _ D3D _ Lib10
Goal. Demonstrate how to work with the new UWBGL _ D3D _ Lib10 library.
Approach. Re-implement Tutorial 10.8 based on the new library to under-
stand how to work with the new functions.
Figure 10.17 is a screenshot of running Tutorial 10.9. This tutorial is identi-
cal to Tutorial 10.8 except that the new implementation takes advantage of the
new WC window functionality provided by the UWBGL _ D3D _ Lib10 library. List-
ing 10.10 shows that, in the CTutorialDlg::OnInitDialog() function, at label
A we initialize the view/controller pair WC window ( m _ view ) as part of the appli-
cation state initialization process. When redrawing the view/controller pair in the
DrawGraphics() function, at label B we call the LoadW2NDCXform() function to
compute and load the M w 2 n operator into the D3D VIEW matrix processor.
Figure 10.17.
Running
Tutorial 10.9.
 
Search WWH ::




Custom Search