Jump to content
  • Advertisement
Sign in to follow this  
mc30900

problom with TriangleStrip

This topic is 4446 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello all. i'm trying to make 2 squares which are touching each other. can anyone tell me why isnt this working (i see only one square)? first of all the vertices:
{-2.0f, 1.0f, 0.0f,  0.0f,0.0f },
	{ 0.0f, 1.0f, 0.0f,  1.0f,0.0f },
	{-2.0f,-1.0f, 0.0f,  0.0f,1.0f },
	{ 0.0f,-1.0f, 0.0f,  1.0f,1.0f },

		{0.0f, 1.0f, 0.0f,  0.0f,0.0f },
	{5.0f, 1.0f, 0.0f,  1.0f,0.0f },
	{0.0f,-1.0f, 0.0f,  0.0f,1.0f },
	{ 5.0f,-1.0f, 0.0f,  1.0f,1.0f },


and i render it like this:
    g_pd3dDevice->SetStreamSource( 0, g_pTriangleList_VB, 0, sizeof(Vertex) );
	g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
	g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 4 );



can anyone tell me what is the problom? thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
I don't have time to draw it out myself, but I highly recommend you do that..

Most of these simple things can be solved by drawing it on paper to make sure that you've got the layout you intended..

Assuming you've got the layout, then change D3DRS_CULLMODE to D3DCULL_NONE - that should give you the shape you desire; if not, then move the vertices until you do...

The next step is to change the vertex/index ordering so that you get the same layout when using D3DCULL_CCW (or D3DCULL_CW).

hth
Jack

Share this post


Link to post
Share on other sites
You're trying to draw 4 triangles with 8 vertices, as if they are two distinct strips. 8 vertices translate to 6 triangles. If you draw 6 triangles with your call, you should see the 2 squares (I guess the 2 spurious triangles are invisible).

It's possible to get things working with strips, but I'd highly suggest working with an indexed triangle list, which is easier conceptually.

Share this post


Link to post
Share on other sites
Yeah, you need a vertex index buffer if you want to draw 2 squares with only 8 vertices, like ET3D said. But if you dont want to use indexed vertices, you will need 12 vertices. I highly suggested using indexes though, for one thing, the vertex buffer is half the size. But yeah, either 6 vertices and a vertex buffer, or 12 vertices and no index buffer. Good luck.

Share this post


Link to post
Share on other sites
It should be possible to do this with a 9 vertex triangle strip, using one vertex to create a degenerate triangle and then switching vertex order for the second quad.

However, that's just unnecessarily complicated, IMO.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!