Skip to main content
GameDev.net gamedev.net
🔒 Locked

D3DPT_TRIANGLESTRIP problems

Started by strokes Jan 23, 2006 at 11:00 AM 0 replies 2.3k views
Original Post
strokes
strokes
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;
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;
Then when i'm rendering i use:
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);
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]
jollyjeffers
jollyjeffers
I think your winding order might be wrong, you're effectively defining your strip as:

1  3| /||/ |2  4


I always define mine as:

1--2  / /3--4


that is:
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;


hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.