Graphics Reference
In-Depth Information
class CGrfxWindowD3D : public CWnd {
.
Source file.
GrfxWindowD3D.h file in the
GrfxWindow folder of the
D3D _ Rectangles2D project.
bool ReplaceDialogControl(HWND hDialogHandle, int id);
.
// this is the Paint/Redraw service function
afx _ msg void OnPaint();
.
// this is the abstract D3D device
LPDIRECT3DDEVICE9 m _ pD3DDevice;
};
Listing 3.2. CGrfxWindowD3D class (Tutorial 3.1).
CGrfxWndD3D class is a subclass of the MFC CWnd class and thus is a simple
CWnd. The CWnd class is
MFC's definition of a generic
window GUI element. This
class supports most default be-
haviors (e.g., mouse events,
redraw/paint events) of a win-
dow.
generic window GUI element. We have already seen an implementation
of the ReplaceDialogControl() function from Tutorial 2.8 where this
function replaces itself into the area defined by the id GUI ID. In the rest
of this section, we will concentrate on the redraw event service function
OnPaint() . We will examine the rest of CGrfxWndD3D in the next chapter.
Rendering. The process of
converting geometries and re-
lated descriptions (e.g., light
and material properties) into
an image. We will discuss the
details of the rendering pro-
cess in later chapters.
For now, we are going to concentrate on the programming code that actually draws
the two squares. For the time being, we are going to assume that a graphics device
is somehow created and initialized and properly referenced by m _ pD3DDevice
(the details will be covered in the next chapter). From our discussion in the previ-
ous chapters, we know drawing should occur when the window manager informs
us that there is a Paint/Redraw event. As pointed out, the OnPaint() function is
the event service routine for MFC's Paint/Redraw events. The two squares are
Render buffer. Hardware
buffers designed to support the
rendering process. We will
discuss these buffers in detail
in later chapters.
drawn in this function. Listing 3.3 shows the programming code where the actual
drawing occurs. We see that:
Step 1: select graphics hardware render buffer. We have set up the
graphics device to draw geometric shapes into an intermediate buffer. The
content of this buffer will be presented to the application only after the
drawing process is completed. In this way, our user will not see partially
drawn images. In this step, we select the appropriate render buffer for sub-
sequent drawings.
Search WWH ::




Custom Search