Graphics Reference
In-Depth Information
void CGrfxWindowD3D::OnPaint() {
. // check to ensure drawing area is defined
Step 1: select graphics hardware render buffer.
m _ pD3DDevice->BeginScene();
//perform all of our drawing
Step 2: initialize selected hardware and set the coordinate system parameters.
m _ pD3DDevice->SetFVF(D3DFVF _ XYZ | D3DFVF _ DIFFUSE);
m _ pD3DDevice->SetRenderState(D3DRS _ CULLMODE, D3DCULL _ NONE);
.
D3DXMATRIX world2ndc;
D3DXVECTOR3 scale(2.0f/width, 2.0f/height, 1.0f);
D3DXVECTOR3 translate(-1.0f, -1.0f, 0.0);
D3DXMatrixTransformation(&world2ndc, ..., scale, ..., translate);
m _ pD3DDevice->SetTransform(D3DTS _ VIEW, &world2ndc);
Step 3: clear drawing buffer and draw two squares.
m _ pD3DDevice->Clear(
... );
DeviceVertexFormat v[4]; // Hardware device vertex format
// First TRIANGLEFAN: The large square
Source file.
GrfxWindowD3D.cpp file in
the GrfxWindow folders of the
D3D _ Rectangles2D project.
v[0].m _ point = D3DXVECTOR3 (160,122,0);
v[1].m _ point = D3DXVECTOR3 ( 80,122,0);
.
m _ pD3DDevice->DrawPrimitiveUP(D3DPT _ TRIANGLEFAN, 2, (CONST void * )v,
... );
// Second TRIANGLEFAN: The small square
v[0].m _ point = D3DXVECTOR3 (160,122,0);
.
m _ pD3DDevice->DrawPrimitiveUP(D3DPT _ TRIANGLEFAN, 2, (CONST void * )v,
... );
Step 4: present the drawing buffer in the application window.
m _ pD3DDevice->EndScene();
m _ pD3DDevice->Present(NULL, NULL, NULL, NULL);
}
Listing 3.3. CGrfxWndD3D::OnPaint() (Tutorial 3.1).
Search WWH ::




Custom Search