Original Post
I'm trying to render a rectangle on my screen as a HUD, I'm declaring 4 vertices for it and rendering it using triangle strips. I am new to DirectX and am unsure of how to use this approach correctly... it is only rendering one of the triangle strips leaving me with only half of my desired rectangle. Here is a sample of the code i'm using; Then when i'm rendering i use: but to no avail... any help would be greatly appreciated, thanks in advance EDIT: adding [ source ] tags in as per the forum guidelines. Makes your post a little easier to read! [Edited by - jollyjeffers on January 23, 2006 11:47:34 AM]
PANEL_CUSTOMVERTEX* pVertices = NULL;
m_pVertexBuffer->Lock(0, 4 * sizeof(PANEL_CUSTOMVERTEX), (void**)&pVertices, 0);
//Set the positions of the vertices
pVertices[0].x = -(m_nWidth) / 2.0f;
pVertices[0].y = -(m_nHeight) / 2.0f;
pVertices[1].x = -(m_nWidth) / 2.0f;
pVertices[1].y = m_nHeight / 2.0f;
pVertices[2].x = (m_nWidth) / 2.0f;
pVertices[2].y = -(m_nHeight) / 2.0f;
pVertices[3].x = (m_nWidth) / 2.0f;
pVertices[3].y = m_nHeight / 2.0f;
pVertices[0].z = 1.0f;
pVertices[1].z = 1.0f;
pVertices[2].z = 1.0f;
pVertices[3].z = 1.0f;
d3DDevice->SetStreamSource(0, m_pVertexBuffer, sizeof(PANEL_CUSTOMVERTEX), sizeof(PANEL_CUSTOMVERTEX));
d3DDevice->SetFVF(PANEL_D3DFVF_CUSTOMVERTEX);
if(m_pTexture != NULL)
{
d3DDevice->SetTexture(0, m_pTexture);
d3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
}
else
{
d3DDevice->SetTexture(0, NULL);
}
d3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);