lock a vertexbuffer,i failed.

Started by
1 comment, last by 88er 20 years, 5 months ago
I can''t lock a vertexbuffer use Lock(0,0,p,D3DLOCK_DISCARD); The vertexbuffer created by D3DUSAGE_WRITEONLY. It''s ok when change to the Lock(0,0,p,0); but i can''t find what''s means to set the D3DLOCK_CARD to zero. which lock parameter is better.
Advertisement
Quote from the SDK:

"The D3DLOCK_DISCARD and D3DLOCK_NOOVERWRITE flags are valid only on buffers created with D3DUSAGE_DYNAMIC."

Dynamic buffers can move in the gfx memory for speed optimization. The Discard flag tells the driver that you don't care, since you don't need the old data anymore, and therefore potentially makes the lock faster.

Note that not all hw support dynamic vb:s.

-Nik

EDIT: Lock parameter 0 simply uses the default lock settings (RW, non-dynamic, blocking).

[edited by - Nik02 on November 12, 2003 4:17:32 AM]

Niko Suni

As a sidenote - if you use the DEBUG DirectX runtime, then D3D will tell you exactly **why** the Lock() call failed.

--
Simon O''Connor
3D Game Programmer &
Microsoft DirectX MVP

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

This topic is closed to new replies.

Advertisement