Skip to main content
gamedev.net
🔒 Locked

Vertices problem

Started by Talib Apr 27, 2004 at 2:11 PM 1 replies 200+ views
Original Post
Talib
Talib
Hi I''ve been working with the DX 9 tutorials. They are not very good at explaing everything and after searching and a lot of reading I finally figured out what vertices and matrices are. Anyway, through my reading, I stumbled upon D3DPT_TRIANGLESTRIP. According to the tutorial, I can add only one extra vertice to create 2 triangles. I tried modifying the following to get the desired effect: CUSTOMVERTEX vertices[] = { { 150.0f, 50.0f, 0.5f, 1.0f, 0xffff0000, }, { 250.0f, 250.0f, 0.5f, 1.0f, 0xff00ff00, }, { 50.0f, 250.0f, 0.5f, 1.0f, 0xff0000ff, }, }; to: CUSTOMVERTEX vertices[] = { { 150.0f, 50.0f, 0.5f, 1.0f, 0xffff0000, }, { 250.0f, 250.0f, 0.5f, 1.0f, 0xff00ff00, }, { 50.0f, 250.0f, 0.5f, 1.0f, 0xff0000ff, }, { 0.0f, 50.0f, 0.5f, 1.0f, 0xffff00ff, }, }; ... if( FAILED( g_pD3DDevice->CreateVertexBuffer( 3*sizeof(CUSTOMVERTEX), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pD3DVertexBuffer, NULL ) ) ) to: if( FAILED( g_pD3DDevice->CreateVertexBuffer( 4*sizeof(CUSTOMVERTEX), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pD3DVertexBuffer, NULL ) ) ) ... g_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1); to: g_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); This however does not seem to work. Any help would be appreciated Talib
Try, try and fucking try again.
Talib
Talib
btw it is Tutorial 2: Vertices in the sample browser.
Try, try and fucking try again.
don
don
The second triangle of your strip has a counter-clockwise winding order and is therefore backfacing and culled.

Vertices submitted as triangle strips are drawn in this order:
0, 1, 2,
1, 3, 2,
2, 3, 4,
3, 5, 4,
etc.

Notice that the odd-numbered triangles have the second and third vertex order reversed. This is so that the triangles will all be drawn with the same winding order.

You can either change the order of the vertices in your array to respect the drawing order listed above, or disable backface culling (D3DRS_CULLMODE = D3DCULL_NONE).

To change the order of the vertices in the array so that both triangles are front-facing, do the following:

From the original 3 vertex array:
1) Swap the second and third vertices
2) Add the new vertex as the first vertex in the array, ahead of the other 3 vertices.



Topic Locked

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

Sign in to reply to this topic.