Graphics Reference
In-Depth Information
B2:
void CDrawAndMouseHandler::OnMouseButton( bool down, unsigned int nFlags,
int hwX, int hwY) {
// hardware to device coordinate transform
HardwareToDevice(hwX, hwY, deviceX, deviceY);
if (nFlags & MK _ LBUTTON) {
// Left mouse button click
theApp.GetModel() .StartDefineGraphicsObject(deviceX, deviceY);
} else if (nFlags & MK _ RBUTTON) {
// Right mouse button click
theApp.GetModel() .MoveGraphicsObject(deviceX, deviceY);
.
void CDrawAndMouseHandler::OnMouseMove( unsigned int nFlags, int hwX, int hwY) {
.
Listing 7.8. (cont.)
7.4
Abstraction of Behavior: A Primitive Hierarchy
From Tutorial 7.1, we understand that the general behaviors of primitives (e.g.,
geometric definition, moving of a primitive) are independent of the graphics API-
specific drawing operations. We saw that the DrawHelper class supports graphics
API-specific implementation of primitive-drawing functions and that the general
primitive classes can work with the DrawHelper class and be defined in a graphics
API-independent manner.
Tutorial 7.2. The Primitive Hierarchy
Tutorial 7.2.
Project Name:
D3D _ ObjectClasses
Library Support:
UWBGL _ MFC _ Lib1
UWBGL _ D3D _ Lib5
Goals. To practice object-oriented design and implementation with the ge-
ometric primitives; experience graphics programming based on abstract be-
havior.
Approach. To study the implementation of a simple primitive hierarchy;
analyze a simple primitive editor design/implementation based on interac-
tion with abstract Primitive class.
Figure 7.8 is a screenshot of running Tutorial 7.2. This tutorial is similar to the
previous one except that the primitives move around in the application window
Search WWH ::




Custom Search