void DrawLine(float Bx, float By, float Ex, float Ey, int A, int R, int G, int B) { LPD3DXLINE line; D3DXCreateLine(d3ddev, &line); D3DXVECTOR2 lines[] = { D3DXVECTOR2(Bx, By), D3DXVECTOR2(Ex, Ey) }; line->Draw(lines, 2, D3DCOLOR_ARGB(A, R, G, B)); line->Release(); }
void DrawRectangle(float x, float y, float w, int h) { D3DXVECTOR2 vLine1[2]; D3DXVECTOR2 vLine2[2]; D3DXVECTOR2 vLine3[2]; D3DXVECTOR2 vLine4[2]; vLine1[0].x = x; vLine1[0].y = y; vLine1[1].x = x; vLine1[1].y = y+h; vLine2[0].x = x+w; vLine2[0].y = y; vLine2[1].x = x+w; vLine2[1].y = y+h; vLine3[0].x = x; vLine3[0].y = y; vLine3[1].x = x+w; vLine3[1].y = y; vLine4[0].x = x; vLine4[0].y = y+h; vLine4[1].x = x+w; vLine4[1].y = y+h; g_pLine->SetWidth(2); g_pLine->SetAntialias(false); g_pLine->SetGLLines(false); g_pLine->Begin(); g_pLine->Draw(vLine1, 2, 0xFF0000FF); g_pLine->Draw(vLine2, 2, 0xFF0000FF); g_pLine->Draw(vLine3, 2, 0xFF0000FF); g_pLine->Draw(vLine4, 2, 0xFF0000FF); g_pLine->End(); }
HRESULT CDrawBrush::Render(LPD3DXLINE pLine,POINT& offset,BOOL zDepth) { HRESULT hr = S_OK; // 如果没有激活则不绘制 if(!m_bIsActive) return hr; m_pSprite->Begin(D3DXSPRITE_ALPHABLEND); if(zDepth) m_fDepthZ = 1 - ((m_mWor._42-offset.y + m_pCurHeight[m_nCurNum])/1000.f); else m_fDepthZ = 0.f; m_pSprite->SetTransform(&m_mWor); m_pSprite->Draw(m_ppTexture[m_nCurNum],0,0, &D3DXVECTOR3((FLOAT)-offset.x/m_fScale,(FLOAT)-offset.y/m_fScale,m_fDepthZ), m_dwColor); m_pSprite->End(); if(!pLine) return hr; float x = m_mWor._41 - offset.x; float y = m_mWor._42 - offset.y; float cx = m_mWor._41 - offset.x + m_pCurWidth[m_nCurNum]; float cy = m_mWor._42 - offset.y + m_pCurHeight[m_nCurNum]; D3DXVECTOR2 vecLine[8] = { D3DXVECTOR2(x,y), D3DXVECTOR2(cx,y), D3DXVECTOR2(cx,y), D3DXVECTOR2(cx,cy), D3DXVECTOR2(cx,cy), D3DXVECTOR2(x,cy), D3DXVECTOR2(x,cy), D3DXVECTOR2(x,y) }; pLine->Draw(vecLine,8,0xFFFF0000); // 红色的线框 return hr; }