#### Archived

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

# Q about dynamic vertex buffers (DX 8)

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

## Recommended Posts

Ok, if I lock a dynamic vertex buffer with the flag NOOVERWRITE and fill some vertices starting from offset O, can I still draw the vertices that are before the offset O or are those vertices somehow invalid? I''m using directX8. Hopefully I was clear enough... Commando Commando''s Base

##### Share on other sites
Yep you can still draw those vertices, you just can''t read or write to them during the lock (because the graphics hardware might be using them).

For a 100 vertex buffer this is fine:
Offs = 0;Lock( Offs, 100, NOOVERWRITE,  )  Fill/Read/Write 100 vertices starting at OffsUnlockDraw*Primitive starting at OffsOffs += 100;Lock( Offs, 100, NOOVERWRITE,  )  Fill/Read/Write 100 vertices starting at OffsUnlockDraw*Primitive starting at Offs

http://www.gamedev.net/community/forums/topic.asp?topic_id=57162

--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

##### Share on other sites
Ok thx. The way I''m trying to do is:

Offs = 0Lock( Offs, 100, DISCARD,  )  Fill 100 vertices starting at OffsUnlockDraw(indexed)Primitive starting at Offs// Do smth like change matricesLock( Offs + 100, 100, NOOVERWRITE,  )  Fill 100 vertices starting at Offs + 100UnlockDraw(indexed)Primitive starting at Offs

That does not properly (crashes at the NOOVERWRITE part). However it works perfectly when I change it to:

Offs = 0Lock( Offs, 100, DISCARD,  )  Fill 100 vertices starting at OffsUnlockDraw(indexed)Primitive starting at Offs// do smth like change matricesLock( Offs, 100, DISCARD,  )  Fill 100 + 100 vertices starting at OffsUnlockDraw(indexed)Primitive starting at Offs

Can''t see a reason why it works with DISCARD but doesn''t with NOOVERWRITE. The VB is big enough (<5000, only >3000 used per frame). The IB is static, could that affect some way? Sure I could use the DISCARD part all the time but then I''m doing quite a lot of unnecessary VB filling, I thought it would be clever to only fill those vertices that are "new".

Commando
Commando''s Base

##### Share on other sites
I just noticed the following thing from nVidia''s dynamicVB header example:

// Use at beginning of frame to force a flush of VB contents on first drawvoid FlushAtFrameStart() { mbFlush = true; }

Is it necessary to flush (=DISCARD on the first Lock) the VB at the beginning of each frame? I don''t flush the VB every frame if the player doesn''t move (so I use the old data from previous frame), could that cause problems? Whatabout Locking outside BegineScene - EndScene, is that legal?

Commando
Commando''s Base

• 40
• 12
• 10
• 10
• 9
• ### Forum Statistics

• Total Topics
631371
• Total Posts
2999607
×