Archived

This topic is now archived and is closed to further replies.

Triangle Strips

This topic is 5898 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

Does anyone know how to draw groups of Triangle Strips efficiently? I mean, I know a way to combine them, but I don''t know whether it''s a good method or not.

Share this post


Link to post
Share on other sites
Try looking through Tutorial 5: textures that came with your DirectX 8 SDK. In Render() you''ll see the following:
  
// Render the vertex buffer contents

g_pd3dDevice->SetStreamSource( 0, g_pVB, sizeof(CUSTOMVERTEX) );
g_pd3dDevice->SetVertexShader( D3DFVF_CUSTOMVERTEX );
g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2*50-2 );

// End the scene

g_pd3dDevice->EndScene();

// Present the backbuffer contents to the display

g_pd3dDevice->Present( NULL, NULL, NULL, NULL );

g_pVB is a variable of the type LPDIRECT3DVERTEXBUFFER8, which in turn is typedef''d as a pointer to a IDirect3DVertexBuffer8. But, you don''t really need to know that. What you do need to know, though, is that you can create multiple vertex buffer pointers, then call the SetStreamSouce() though DrawPrimative() for each vertex buffer you have- that''s the place in render() to do it.

To make life even easier, try implementing it as an array of verticies...

-Tok.







-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"Hey, I was''t joking... You really /could/ be "boinked" by some irate looney wielding a rubber malet." -Baldor the Bold

Share this post


Link to post
Share on other sites
So how do most people render a sphere?
I guess I''m not clear enough huh?
Well basically, a cylinder can be rendered like this...
|\|\|\| ...wrapped into a circle, which is easy to do.

but a sphere would need this...
|\|\
|\|\|\|
|\|\|\|\|
|\|\|\|
|\|\

Would rendering each level seperately be better than combining all the levels?

Cause I keep thinking that making a lot of DrawPrimitive calls is rather inefficient.

Share this post


Link to post
Share on other sites
G''day!

You can stitch triangle strips together using degerate (0 volume) triangles. If you have a strip (#s represent vertex numbers) 0-1-2-3-4 and then a strip below it 5-6-7-8-9 you can stitch them together by doing something like 0-1-2-3-4-4-5-5-6-7-8-9.

I''m a little tired at the moment so that may not be exactly right, but the concept is. Your biggest concern is that since the winding order reverses every second triangle, you have to have the right number of degenerate triangles so that the winding on your next strip is correct.


Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites
Great, I didn''t know you could do that. (Actually I did cause I asked that question a while ago on a newsgroup, but I hope you feel better. At least others can see it.)

Share this post


Link to post
Share on other sites