/* g_ed.lastKey is the last windows key pressed. You may have to change this variable(s) to suit your app. */ static void UpdatePlaneRotationMatrices(D3DMATRIX* mat1, D3DMATRIX* mat2) { static float fRotPlane1 ; static float fRotPlane2 ; const float fSkip = 2.0f ; switch(g_ed.lastKey) { case VK_F1 : fRotPlane1 += fSkip ; break ; case VK_F2 : fRotPlane1 -= fSkip ; break ; case VK_F3 : fRotPlane2 += fSkip ; break ; case VK_F4 : fRotPlane2 -= fSkip ; break ; } // rotate on Y Axis only SetYRotate(mat1, D3DXToRadian(fRotPlane1)) ; SetYRotate(mat2, D3DXToRadian(fRotPlane2)) ; } /* This procedure sets up a new vertexshader based on certain keys being pressed */ static void SetPlaneBlendVS(IDirect3DDevice8* device8) { static DWORD dwVSIndex = NON_BLEND_ONLY ; switch(g_ed.lastKey) { case '1' : dwVSIndex = BASIC_VS ; break ; case '2' : dwVSIndex = BASIC_VS_WITHLIGHT ; break ; case '3' : dwVSIndex = BLEND_ONLY ; break ; case '4' : dwVSIndex = NON_BLEND_ONLY ; break ; case '5' : dwVSIndex = BLEND_WITH_LIGHT ; break ; } SETVERTEXSHADER(device8, g_pbVS[dwVSIndex]) ; } /* PROCEDURE DisplayPlaneBlend. void DisplayPlaneBlend(IDirect3DDevice8* device8) ; This procedure is called every render loop. It does the following things: 1. Updates the plane rotation matrices based on keyboard input. 2. Sets the world matrix to identity. 3. Sets the vertex shader based on keyboard input. 4. Loads the verex shader constants. These constants are independant of the different vertex shaders. 5. Binds the stream source to the plane vertex buffer and the indices to the plane index buffer. Sets the current texture for the stage to the plane texture. 6. Finally calls DrawIndexedPrimitive. You will find the macros for DRAWIP, SETINDICES and others in the file UtilDefines.h */ void DisplayPlaneBlend(IDirect3DDevice8* device8) { D3DMATRIX idmat ; // update rotation matrices based on certain key press events. UpdatePlaneRotationMatrices(&g_rotMatPlane1, &g_rotMatPlane2) ; // identity world matrix D3DXMatrixIdentity((D3DXMATRIX*)&idmat) ; SetPlaneBlendVS(device8) ; LoadPlaneBlendConstants(device8, &idmat, &g_rotMatPlane1, &g_rotMatPlane2) ; SETSTREAMSOURCE(device8, 0, g_pbVB, SIZEOFVERTEXB2) ; SETINDICES(device8, g_pbIB, 0) ; SETTEXTURE(device8, 0, NULL) ; SETTEXTURE(device8, 0, g_pbTexture) ; // draw the plane DRAWIP(device8, D3DPT_TRIANGLELIST, 0, g_dwpbNumVertices, 0, g_dwpbNumIndices) ; }