Graphics Reference
In-Depth Information
specific drawing is implemented by calling the primitive draw routine through the
D3DDrawHelper object ( m _ DrawHelper ).
The Tutorial 7.1 application. As in all the tutorials, an instance of CModel is
defined in the CTutorialApp class. Recall that the CTutorialApp class is the
abstract representation of the running program and that there is only one instance
of this object. By defining the CModel instance in the CTutorialApp class, we are
guaranteed that there will only be one instance of the CModel object. Once again,
the CTutorialDlg class represents the application dialog window. Listing 7.7
shows the declarations of GUI event service routines (at label A) and GUI control
variables (at label B). At label C, the CDrawAndMouseHandler class is similar
to that from Tutorial 5.2 (Listing 5.14), where this is the view/controller pair
abstraction and implements the drawing area in the application main window.
Listing 7.8 shows the CDrawAndMouseHandler methods for drawing (A1) and
handling of mouse events (B1). At label A2, we see the the implementation of
DrawGraphics() invokes the CModel::DrawModel() function for drawing. At
label B2, we see that mouse events are translated into appropriate methods on the
CModel class for the definition of the primitive geometries.
Source file.
DrawAndMouseHandler.h/
.cpp files in the Win-
dowHandler folder of the
D3D _ ObjectsAndAttributes
project.
class CDrawAndMouseHandler : public UWBD3D _ WindowHandler {
.
bool Initialize(CDialog& parent _ dlg, int control _ id);
void DrawGraphics();
.
A1:
B1:
void OnMouseButton( bool down, unsigned int nFlags, int windowX, int windowY);
void OnMouseMove( unsigned int nFlags, int windowX, int windowY);
.
A2:
void CDrawAndMouseHandler::DrawGraphics() {
// initialize Graphics API RC and sets up transformation processors
m _ pD3DDevice->SetTransform(D3DTS _ VIEW, &world2ndc);
.
theApp.GetModel() .DrawModel();
// Get the instance of CModel and redraw
.
Listing 7.8. The CDrawAndMouseHandler class (Tutorial 7.1).
Search WWH ::




Custom Search