question about polygons

Started by
3 comments, last by Seriema 22 years, 2 months ago
Hi! I'm still in the process of learning DirectX 8.1 and DirectGraphics. I just got some polygons on me screen *yeey* following a tutorial of course I've understood that you can make your own Vertex struct (is there really no MS made?). The tutorial I read was from www.drunkenhyena.com (tut nr 2a: http://www.drunkenhyena.com/docs/d3d8/d3d_lesson2b.phtml) and then I looked at nexe.gamedev.net (tut on drawing a triangel: http://nexe.gamedev.net/tutorials/ViewTutorial.asp?tutorialfile=Pages/Tutorial3.myxml). They're very different! Drunken Hyena:
    
hr=g_d3d_device->CreateVertexBuffer(7*sizeof(my_vertex), D3DUSAGE_WRITEONLY, D3D8T_CUSTOMVERTEX, D3DPOOL_MANAGED,
&g_vb);

hr=g_vb->Lock(0, 0, &vb_vertices, 0);

memcpy(vb_vertices, g_vertices, sizeof(g_vertices) );

g_vb->Unlock();
    
Nexe: doesn't do any of that... doesn't even use a Vertex Buffer... What is the difference?! I mean, what is the gains and losses? Please help, I'm really lost here... thanx [Edit] source was weird looking }+TITANIUM+{ Edited by - Seriema on February 7, 2002 3:43:35 AM Edited by - Seriema on February 7, 2002 3:44:26 AM
[ ThumbView: Adds thumbnail support for DDS, PCX, TGA and 16 other imagetypes for Windows XP Explorer. ] [ Chocolate peanuts: Brazilian recipe for home made chocolate covered peanuts. Pure coding pleasure. ]
Advertisement
quote:Original post by Seriema


I''ve understood that you can make your own Vertex struct (is there really no MS made?).


Yes there is. I found it trawling through the d3dx.lib/.h files.

It''s D3DXVERTEX3. This library also has loads of USEFUL Matrix functions too. I''m glad I bumped into this library (although now I''m going to emulate what it does). But it''s a useful starting point. I personally like the idea of creating my own custom vertex structure. This way, should you wish to add a OpenGL renderer in the future.

quote:
Nexe:
doesn''t do any of that... doesn''t even use a Vertex Buffer...



What is the difference?! I mean, what is the gains and losses?


As far as I know (which is very little). I think the vertex buffer gets moved into the 3D Card''s memory, rather than staying in system memory. This would make it faster to access for drawing. Am I right on this?

Oli


All the best problems start with C

The Most Boring Website Ever?
G''day!

Using Vertex Buffers is the way to go. I think you''ll find that if you check out the other Nexe tutorials they use VBs. He made the decision not to use them in that tutorial to make the code a bit easier to understand. I used VBs for the same type of tutorial because I figured it''d be best to introduce them sooner.

When you use DrawPrimitiveUP, your data gets copied into an internal VB and then drawn so there are extra stages and it''s less efficient.

Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena
ok!

I was hoping to be able to skip that memcpy(), I really hate those. If they aren''t used correctly you get weird bugs that take forever to find!

Isn''t there any way to get rid of them?..
[ ThumbView: Adds thumbnail support for DDS, PCX, TGA and 16 other imagetypes for Windows XP Explorer. ] [ Chocolate peanuts: Brazilian recipe for home made chocolate covered peanuts. Pure coding pleasure. ]
quote:Original post by Seriema
ok!

I was hoping to be able to skip that memcpy(), I really hate those. If they aren''t used correctly you get weird bugs that take forever to find!

Isn''t there any way to get rid of them?..

You can use that pointer that''s returned by lock as an array of vertices and iterate through them (with a for loop for example). This will be a LOT slower than the memcpy though.

On my website there is a wrapper for Vertex Buffers to simplify their use. http://www.drunkenhyena.com/docs/dhPrimitive.phtml




Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena

This topic is closed to new replies.

Advertisement