//////////////////////////////////////////////////////////////////////////////////////////////////// // GenerateFillVerticesD3DColor() // //////////////////////////////////////////////////////////////////////////////////////////////////// void CVertexGenerator::GenerateFillVerticesD3DColor( const WinRect & rectToFill, const bool bSetStream, D3DCOLOR d3dColor ) { UICOLOURFILLVERTEX * pVertArray; if( CVBIBManager::Get()->LockDynamicVertexBuffer( &m_sVGState.hPredefinedDynBuffers[ePDBT_UIFillVB], 4, (void**) &pVertArray ) == false ) { // Failed to lock the vertex buffer. _ASSERT( false ); return; } // 2d texturing, adjust the vertex positions slightly. float fMinX, fMinY, fMaxX, fMaxY; fMinX = (float) rectToFill.Min().X() - 0.5f; fMinY = (float) rectToFill.Min().Y() - 0.5f; fMaxX = (float) rectToFill.Max().X() - 0.5f; fMaxY = (float) rectToFill.Max().Y() - 0.5f; pVertArray[0].x = fMinX; pVertArray[0].y = fMinY; pVertArray[0].z = 0.5f; pVertArray[0].rhw = 1.0f; pVertArray[0].color = d3dColor; pVertArray[1].x = fMaxX; pVertArray[1].y = fMinY; pVertArray[1].z = 0.5f; pVertArray[1].rhw = 1.0f; pVertArray[1].color = d3dColor; pVertArray[2].x = fMinX; pVertArray[2].y = fMaxY; pVertArray[2].z = 0.5f; pVertArray[2].rhw = 1.0f; pVertArray[2].color = d3dColor; pVertArray[3].x = fMaxX; pVertArray[3].y = fMaxY; pVertArray[3].z = 0.5f; pVertArray[3].rhw = 1.0f; pVertArray[3].color = d3dColor; // Finished adding verts, unlock. CVBIBManager::Get()->UnlockDynamicVertexBuffer( &m_sVGState.hPredefinedDynBuffers[ePDBT_UIFillVB] ); if( bSetStream == true ) { CVBIBManager::Get()->SetVertexStream( &m_sVGState.hPredefinedDynBuffers[ePDBT_UIFillVB] ); } }
//////////////////////////////////////////////////////////////////////////////////////////////////// // GenerateUITexturedVertices() // //////////////////////////////////////////////////////////////////////////////////////////////////// void CVertexGenerator::GenerateUITexturedVertices( const TEXHANDLE hTexture, const WinRect & rectToDraw, const bool bSetStream ) { _ASSERT( hTexture != INVALID_TEX_HANDLE ); float fMinX, fMinY, fMaxX, fMaxY; float fU1, fV1; DWORD dwWidth, dwHeight; UIVERTEX * pVertArray; CVRAMManager::Get()->GetOriginalDimensions( hTexture, &dwWidth, &dwHeight ); if( CVBIBManager::Get()->LockDynamicVertexBuffer( // &m_sVGState.hUITexVertsVB, &m_sVGState.hPredefinedDynBuffers[ePDBT_UITexVB], 4, (void**) &pVertArray ) == false ) { // Failed to lock the vertex buffer. _ASSERT( false ); return; } // 2d texturing, adjust the vertex positions slightly. fMinX = (float) rectToDraw.Min().X() - 0.5f; fMinY = (float) rectToDraw.Min().Y() - 0.5f; fMaxX = (float) rectToDraw.Max().X() - 0.5f; fMaxY = (float) rectToDraw.Max().Y() - 0.5f; // Calculate our uv coords. fU1 = 1.0f; fV1 = 1.0f; if( rectToDraw.XSize() < (int)dwWidth ) { fU1 = (float) rectToDraw.XSize() / (float) dwWidth; } if( rectToDraw.YSize() < (int)dwHeight ) { fV1 = (float) rectToDraw.YSize() / (float) dwHeight; } pVertArray[0].x = fMinX; pVertArray[0].y = fMinY; pVertArray[0].z = 0.5f; pVertArray[0].rhw = 1.0f; pVertArray[0].fU = 0.0f; pVertArray[0].fV = 0.0f; pVertArray[1].x = fMaxX; pVertArray[1].y = fMinY; pVertArray[1].z = 0.5f; pVertArray[1].rhw = 1.0f; pVertArray[1].fU = fU1; pVertArray[1].fV = 0.0f; pVertArray[2].x = fMinX; pVertArray[2].y = fMaxY; pVertArray[2].z = 0.5f; pVertArray[2].rhw = 1.0f; pVertArray[2].fU = 0.0f; pVertArray[2].fV = fV1; pVertArray[3].x = fMaxX; pVertArray[3].y = fMaxY; pVertArray[3].z = 0.5f; pVertArray[3].rhw = 1.0f; pVertArray[3].fU = fU1; pVertArray[3].fV = fV1; // Finished adding verts, unlock. CVBIBManager::Get()->UnlockDynamicVertexBuffer( &m_sVGState.hPredefinedDynBuffers[ePDBT_UITexVB] ); if( bSetStream == true ) { CVBIBManager::Get()->SetVertexStream( &m_sVGState.hPredefinedDynBuffers[ePDBT_UITexVB] ); } }